上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 182 下一页
摘要: 同2606View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;#define eps 1.0e-8#define maxn 1005struct XPoint{ int x, y;} point[maxn];struct Line{ int a, b; double k; bool end;} line 阅读全文
posted @ 2011-10-06 10:10 undefined2024 阅读(254) 评论(0) 推荐(0)
摘要: f[n] += 1 + f[i] * (n - i);这个公式可以利用sum(前n项和)进行O(1)的递推。也可以自己根据结果总结规律f[i]= 3 * f[i -1] - f[i - 2];但是快速幂会超时。所以想到有循环节,写个程序找循环节,发现为75000,所以只需要求出前75000个即可。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 100005#defin 阅读全文
posted @ 2011-10-06 10:02 undefined2024 阅读(189) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 20char st1[maxl], st2[maxl];int getd(char *st, char a){ int len = strlen(st); int x = -1; for (int i = 0; i < len; i++) if (st[i] == a) { x = i; ... 阅读全文
posted @ 2011-10-05 21:19 undefined2024 阅读(195) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int t, x, m;int n;void input(){ scanf("%d%d%d", &t, &x, &m); n = 0x3f3f3f3f; for (int i = 0; i < m; i++) { int a, b; scanf("%d%d", & 阅读全文
posted @ 2011-10-05 18:56 undefined2024 阅读(138) 评论(0) 推荐(0)
摘要: 题意:给出d,n,求d/1+d/2+……+d/n,所有除法向上取整。分析:我们从两边同时计算,算d/i时,同时算出由面所有d/x等于i的项的和,直到两端汇合。这些x中的一个应该是minx = d/i向上取整,因为minx*i>=d且(minx-1)*i<d,所以d/minx<=i且d/(minx-1)>i。也就是说minx再小一点那么d/minx向上取整的结果就会比i大。复杂度为sqrt(n)。View Code #include <iostream>#include <cstdlib>#include <cstring>#inclu 阅读全文
posted @ 2011-10-05 18:38 undefined2024 阅读(234) 评论(0) 推荐(0)
上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 182 下一页