摘要: 简单题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)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;int n;int f[] ={ 3, 5, 8, 12, 20, 34, 57, 98, 170, 300, 536, 966, 1754, 3210, 5910, 10944, 20366, 38064, 71421, 134480, 254016};int main(){ //freopen 阅读全文
posted @ 2011-10-05 16:53 undefined2024 阅读(250) 评论(0) 推荐(0)
摘要: 题意:这题的本质是给定若干条边,问能否用其中的一些组成多边形。分析:先排序,看前i个的和是否大于第i+1个,若大于则可以View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 30double f[maxn];int n;void input(){ for (int i = 0; i < n; i++) scanf(& 阅读全文
posted @ 2011-10-05 16:13 undefined2024 阅读(231) 评论(0) 推荐(0)