[topcoder]SRM 633 DIV 2

第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076

模拟就可以了。

#include <vector>
#include <algorithm>

using namespace std;

class Target {
public:
  vector <string> draw(int n) {
    vector<string> result(n, string(n, ‘ ‘));
    int x = 0;
    int y = 0;
    while (n >= 1) {
      for (int i = 0; i < n; i++) {
        result[x + i][y] = ‘#‘;
        result[x][y + i] = ‘#‘;
        result[x + n - 1][y + i] = ‘#‘;
        result[x + i][y + n - 1] = ‘#‘;
      }
      x += 2;
      y += 2;
      n -= 4;
    }
    return result;
  }
};

第二题,想了很久。最后发现用三角形的A+B>=C,一个一个推,可以推出N条边所组成的多边形(开口)的距离范围。http://apps.topcoder.com/wiki/display/tc/SRM+633#Jumping

有详细的图示。

#include <vector>
#include <algorithm>
#include <string>
#include <algorithm>
using namespace std;

class Jumping {
public:
  string ableToGet(int x, int y, vector <int> jumpLengths) {
    double d = sqrt(1.0 * x * x + 1.0 * y * y);
    sort(jumpLengths.begin(), jumpLengths.end());
    double low = jumpLengths[0];
    double high = jumpLengths[0];
    for (int i = 1; i < jumpLengths.size(); i++) {
      low = max(0.0, jumpLengths[i] - high);
      high = high + jumpLengths[i];
    }
    if (d >= low && d <= high) {
      return "Able";
    } else {
      return "not able";
    }

  }

};

第三题,没做。后来看题解,就是用LCD和GCD的限制,得到x*y,然后穷举搜索。用DFS。

时间: 2024-10-10 05:04:55

[topcoder]SRM 633 DIV 2的相关文章

TopCoder SRM 633 Div.2 500 Jumping

题意:给一个点(x,y),给一些步长delta1,delta2...deltaN,问从(0,0)严格按照步长走完N步后能否正好到达(x,y)点. 解法:其实就是判断这些线段和(0,0)-(x,y)这条线段能否构成一个多边(角?)形的问题,只需判断最长的边是否不大于于所有边长和的一半即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #inclu

TopCoder SRM 634 Div.2[ABC]

TopCoder SRM 634 Div.2[ABC] ACM 题目地址: TopCoder SRM 634 赛后做的,感觉现场肯定做不出来Orz,简直不能多说. Level One-MountainRanges[水题] 题意: 问序列中有几个完全大于旁边的峰. 分析: 傻逼题,不多说. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * File: one.cpp * Create Date: 2014-09-26 21:01:23 * Desc

TopCoder SRM 628 DIV 2

250-point problem Problem Statement    Janusz is learning how to play chess. He is using the standard chessboard with 8 rows and 8 columns. Both the rows and the columns are numbered 0 through 7. Thus, we can describe each cell using its two coordina

TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization &amp; Codeforces 839 E

传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相加,含有n个不同变量的式子的最大值. 另外限制了每一个变量的最大最小值R[i]和L[i]和所有变量之和的最大值Max. n<=13 题外话: 刚开始做这道题的时候,感觉意外眼熟? codeforces 839 E(此题的退化版):http://codeforces.com/contest/839/pro

[topcoder]SRM 646 DIV 2

第一题:K等于1或者2,非常简单.略.K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考. 第二题:http://www.cnblogs.com/lautsie/p/4245242.html BFS和DFS都可以,注意的是,写的时候,可以往que里几个东西一起扔,就不用建立对象了.也可以直接用二维矩阵记录blocked和visited. 剪枝什么的,最基本的是发现其实在步数限制的情况下,棋盘就是有界的了. 第三题:http://ap

Topcoder SRM 648 (div.2)

第一次做TC全部通过,截图纪念一下. 终于蓝了一次,也是TC上第一次变成蓝名,下次就要做Div.1了,希望div1不要挂零..._(:зゝ∠)_ A. KitayutaMart2 万年不变的水题. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<set> #include<map&

TopCoder SRM 596 DIV 1 250

body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } Problem Statement      You have an array with N elements. Initially, each element is 0. You can perform the following operations: Increment operation:

Topcoder SRM 687 (Div 2) 250.Quorum

Problem Statement   In one organization they have n different committees. The organization has a very large number of employees. Each employee is a member of each committee. Each committee has a quorum: the smallest number of members that have to be

Topcoder SRM 687 (Div 2) 500.Quacking

Problem Statement   Ducks have started mysteriously appearing in your room. All ducks make the same sound: "quack". Each duck makes the sound one or more times, one after another. For example, valid sounds for a single duck are "quack"