URAL 1224. Spiral (规律)】的更多相关文章

1224. Spiral Time limit: 1.0 second Memory limit: 64 MB A brand new sapper robot is able to neutralize mines in a rectangular region having integer height and width (N and M respectively). Before the robot begins its work it is placed near the top le…
Growing Rectangular Spiral 题目描述 A growing rectangular spiral is a connected sequence of straightline segments starting at the origin. The fi rst segment goes right (positive x direction). The next segment goes up (positive y direction). The next segm…
题意:在[L, R]之间求:x是个素数,因子个数是素数,同时满足两个条件,或者同时不满足两个条件的数的个数. 析:很明显所有的素数,因数都是2,是素数,所以我们只要算不是素数但因子是素数的数目就好,然后用总数减掉就好.打个表,找找规律,你会发现, 这些数除外的数都是素数的素数次方,然后就简单了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include &…
G - Gray CodeTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/G Description Denis, Vanya and Fedya gathered at their first team training. Fedya told them that he knew the algorithm for c…
1180. Stone Game Time limit: 1.0 second Memory limit: 64 MB Two Nikifors play a funny game. There is a heap of N stones in front of them. Both Nikifors in turns take some stones from the heap. One may take any number of stones with the only condition…
2045. Richness of words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2045 Description For each integer i from 1 to n, you must print a string si of length n consisting of lowercase Latin letters. The string si must contain exactly i distinct pa…
2037. Richness of binary words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2037 Description For each integer i from 1 to n, you must print a string si of length n consisting of letters 'a' and 'b' only. The string si must contain exactly i dis…
ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺塔问题,给定一串只有(A, B, C)的字符串(A代表在第一根柱子,B代表在第二根柱子,C代表在第三根柱子),从前往后代表盘子的大小,第 i 个字母代表di i 个盘子在某个柱子上.问移动给定字母状态的盘子最少需要多少步. 思路:首先,从后往前看(最大的盘子),如果不在当前柱子上,那么移动到目标柱子需要 2…
Richness of binary words 题目链接: http://acm.hust.edu.cn/vjudge/contest/126823#problem/B Description For each integer i from 1 to n, you must print a string s i of length n consisting of letters 'a' and 'b' only. The string s i must contain exactly i di…
题意:构造一个数列,使得它们的区间和的种类最少,其中数列中不同的数的数目不少于k. 析:我们考虑0这个特殊的数字,然后0越多,那么总和种类最少,再就是正负交替,那么增加0的数量. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath&g…