题目链接:http://lightoj.com/volume_showproblem.php?problem=1234 给你一个数n,让你求 这个要是直接算的话肯定TLE,要是用1e8的数组预处理存储答案也一定MLE。 所以我用1e6的数组存储每100个数的答案,然后每次给你n的时候顶多算99次。 ...
分类:
其他好文 时间:
2016-03-27 19:15:58
阅读次数:
146
分析:一看就是求最短路,然后用dij,果断错了一发,发现是3次方,有可能会出现负环 然后用spfa判负环,然后标记负环所有可达的点,被标记的点答案都是“?” #include<cstdio> #include<cstring> #include<queue> #include<cstdlib> #i ...
分类:
其他好文 时间:
2016-03-26 18:37:33
阅读次数:
159
思路:直接暴力会超内存 只存n/50个数就可以了 需要哪个数再算就好了
分类:
其他好文 时间:
2016-03-21 00:04:26
阅读次数:
244
转载自:http://blog.csdn.net/xindoo/article/details/9173949 暴力TLE 状态压缩+dp
分类:
其他好文 时间:
2016-03-20 00:32:49
阅读次数:
180
In 'MonkeyLand', there is a traditional game called "Bamboo Climbing". The rules of the game are as follows: 1) There are N monkeys who play this game
分类:
其他好文 时间:
2016-03-19 22:48:34
阅读次数:
246
水题 有t组数据 每组数据有a b 两个数 求a b之间有多少个素数 打表筛选即可 思路:先打一个素数表 找到第一个大于a的素数的倍数j 从j开始筛 筛到b为止 用flag标记 然后筛第二个素数 一直筛到sqrt(b)为止 剩下的就都是素数了 水题
分类:
其他好文 时间:
2016-03-19 21:24:16
阅读次数:
468
题意 给你一个数n 求满足lcm(a, b) == n, a <= b 的 (a,b) 的个数 容易知道 n 是a, b的所有素因子取在a, b中较大指数的积 先将n分解为素数指数积的形式 n = π(pi^ei) 那么对于每个素因子pi pi在a,b中的指数ai, bi 至少有一个等于pi, 另一
分类:
其他好文 时间:
2016-03-19 20:59:18
阅读次数:
142
Description In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are given n, yo
分类:
其他好文 时间:
2016-03-03 20:52:03
阅读次数:
270
区间DP。 这题好难想....做区间DP专题的时候,第一题看的就是这题,发现不会然后一直没去做,直到今天专题中其余的题都切完了再看这题...依旧无头绪,还是看了题解....看了也发现好难。。。 #include<cstdio> #include<cstring> #include<cmath> #i
分类:
其他好文 时间:
2016-02-29 14:17:21
阅读次数:
147