上一页 1 ··· 62 63 64 65 66 67 68 69 70 ··· 182 下一页
摘要: 题意:给出n,求1/n=1/x+1/y(n,x,y=1,2,3...)的解的个数分析:n = (x*y)/(x+y) (x+y)*n = x*y设x = n+a; y = n+b带入可以得到n*n = a*b题目就转化成了求所有整数对使得a*b = n*n。即求n*n的约数个数,由于约数都是成对出现的,两数乘积为n^2,为奇数是因为n与n成对出现,而只计算了1次。为避免重复,设约数个数为p,(p + 1)/2即为所求。然而n*n过大不能直接求约数。我们用求质因子的方法求约数个数,我们只需求n的素因子,每个个数乘2即为n*n的每个素因子个数。View Code #include <iost 阅读全文
posted @ 2011-10-08 12:46 undefined2024 阅读(220) 评论(0) 推荐(0)
摘要: 枚举View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 15struct Point{ int x, y;}point[maxn], s;int n, f[maxn];void input(){ scanf("%d%d", &s.x, &s.y); scanf("%d%d&q 阅读全文
posted @ 2011-10-07 18:52 undefined2024 阅读(205) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 30#define maxl 1005bool f[maxn][maxl];int n;void input(){ memset(f, 0, sizeof(f)); scanf("%d", &n); for (int i = 0; i < n; i++) { char st[4]; 阅读全文
posted @ 2011-10-06 15:32 undefined2024 阅读(203) 评论(0) 推荐(0)
摘要: 线段树这种每次在第几个位置插入元素的题,都可以用线段树,从最后一次插入开始来查找每次插入的元素的最终位置。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 2000005#define maxn 2005struct Elem{ bool cmd; int p; char ch; int pos;} elem[maxn];struct Node{ Node *pl; N 阅读全文
posted @ 2011-10-06 15:08 undefined2024 阅读(973) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 20int n, m, k;int f[maxn], g[maxn];void input(){ scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < k; i++) scanf("%d", & 阅读全文
posted @ 2011-10-06 10:19 undefined2024 阅读(188) 评论(0) 推荐(0)
上一页 1 ··· 62 63 64 65 66 67 68 69 70 ··· 182 下一页