摘要:http://codeforces.com/contest/712/problem/C 要使得把三角形由边长n变成m,等价于由m变成n 如果是从n变成m,则很难判断每次判断变成多少。比如22的变成4,一开始那一条边变成什么都是可以得,都是满足三角形规律的。 但是如果你直接变成m,则后面的得不到最优。
阅读全文
摘要:http://vjudge.net/problem/UVA-11582 http://acdream.info/problem?pid=1060 首先证明下为什么暴力枚举n^2项以后就一定会重复。 我们说如果fib数列重复,只需要fib[i - 1] == f[0] && fib[i] == fib
阅读全文
摘要:http://codeforces.com/contest/735/problem/D 这题其实我还不是很懂,那个只是猜想,然而却用了。 只想说说找到第一小于n的素数这种思路是不行的。 121 = 113 + 7 + 1,不能拆成1,但是答案是一样,。 1354 = 1327 + 23 + 4 (2
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1220 一开始的做法是,先暴力算出一个面,就是n * n的面,能有多少对。记作face 然后从上开始算下来,最上一层,face个,然后第二层,有n * n * (up - 1)个。 递推下去,up是在第i层上面有多
阅读全文
摘要:https://www.hackerrank.com/contests/101hack41/challenges/arias-loops 可以看我以前的笔记,http://www.cnblogs.com/liuweimingcprogram/p/6091396.html 或者我在discusses的
阅读全文
摘要:1、给定n个数字,要求选出3个数,其和为3的倍数。 思路,分类,把每个数字%3后,0、1、2、的分成三类,然后按类计算。 ①、三个数来自同一个类,②、来自0、1、2各一类。 2、将r个相同的球放到n个不同的盒子里面,盒子的球数不限,求方案数。 将r个球用0表示,就是000000....000,然后分
阅读全文
摘要:17115 ooxx numbers 时间限制:1000MS 内存限制:65535K提交次数:0 通过次数:0 题型: 编程题 语言: G++;GCC Description 输入格式 there are many cases in the input. for each line there is
阅读全文
摘要:17997 Simple Counting 时间限制:2000MS 内存限制:65535K提交次数:0 通过次数:0 题型: 编程题 语言: 不限定 Description 输入格式 The first line of the input is an integer T , indicates th
阅读全文
摘要:17995 Stupid thief 时间限制:1000MS 内存限制:65535K提交次数:0 通过次数:0 题型: 编程题 语言: 不限定 Description 输入格式 The input will contain multiple cases. The first line is a in
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5869 题意:给定一个数组,然后给出若干个询问,询问[L, R]中,有多少个子数组的gcd是不同的。 就是[L, R]中不同区间的gcd值,有多少个是不同的。 给个样例 3 37 7 71 21 33 3 数学背景
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5974 遇到数学题真的跪。。 题目要求 X + Y = a lcm(X, Y) = b 设c = gcd(x, y); 那么可以表达出x和y了,就是x = i * c; y = j * c; 其中i和j是互质的。
阅读全文
摘要:http://www.ifrog.cc/acm/problem/1049 这些数学题我一般都是找规律的。。 先暴力模拟了前面的那些,然后发现(x, y) = (x, y - 1) + (x - 1, y)得到。 但是这是没用的。因为要得到(x, y - 1)这些,又要递归处理的话,就会GG。 然后找
阅读全文
摘要:http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最短的那条边最大。 看样例2就知道,因为10、8、7和10、8、2组合后,min = 8,是最大的。
阅读全文
摘要:Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of paintin
阅读全文
摘要:https://www.hackerrank.com/contests/hourrank-13/challenges/arthur-and-coprimes 要求找出所有x <= n x + n = x ^ n的个数。 首先如果n的二进制是100101010 n = 298 这样的话 先考虑最高位的
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3579 注意下最后的答案等于0是不行的,因为要的是正整数 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #incl
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1573 解出最小解rr后,特判下其是否为0,为0的话,就直接n / lcm 否则 + 1 #include <cstdio> #include <cstdlib> #include <cstring> #inclu
阅读全文
摘要:711323 97935537 475421538 1090116118 2032082 120922929 951016541 15898 418373 161478614 149488440 1748022751 21618619576 810918992 241779667 177261674
阅读全文
摘要:1077 韩信点兵 时间限制:500MS 内存限制:65536K 提交次数:1103 通过次数:99 题型: 编程题 语言: G++;GCC Description 相传汉高祖刘邦问大将军韩信统御兵士多少,韩信答说,每3人一列余1人、5人一列余2人、7人一列余4人、13人一列余6人、 17人一列余2
阅读全文
摘要:求一个最小的正整数x,使得(y + x) (y - x) = n成立 考虑一下n的分解因式。 可能会想到枚举n的约数,那么a * b = n成立,取最小的x即可 但是要枚举到n / 2,这样会超时。 因为要使得a * b = n,那么a和b中最大的数字最多是sqrt(n),因为不可能是两个大于sqr
阅读全文