First question, http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076.
The simulation is ready.
#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;} ;
The second question, thought for a long time. Finally, we find that the a+b>=c of the triangle, a push, can introduce the distance range of the polygon (opening) composed of n edges. Http://apps.topcoder.com/wiki/display/tc/SRM+633#Jumping
There are detailed illustrations.
#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 '; }} ;
The third question, did not do. Later see the puzzle, is to use the LCD and gcd restrictions, get x*y, and then exhaustive search. With DFS.
[TopCoder] SRM 633 DIV 2