摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#define maxn 100005bool is[maxn];long long prm[maxn];int n, a, b, m, p, q;int getprm(int n){ int i, j, k = 0; int s, e = (int) (sqrt(0.0 + n) + 1); m 阅读全文
posted @ 2011-06-16 20:38 undefined2024 阅读(230) 评论(0) 推荐(0)
摘要: 题意:遗产总量为1,n个继承人,第i人获得1/ai,1/ai随i增加而减少,要求分给n个人后必须有剩余,而且要求剩余最少。分析:高精度,用java做我们认为最开始财产是1/1我们对于财产剩余1/a时,应分给当前继承人1/(a+1)的财产。然后财产还剩下1/(a * (a + 1))。按此递推。为什么是正确的很难证明,只能经过多次尝试,或者打个低效递归检验一下。View Code import java.util.*;import java.io.*;import java.math.*;publicclass Main { publicstaticvoid main(String[] a... 阅读全文
posted @ 2011-06-16 19:00 undefined2024 阅读(316) 评论(0) 推荐(0)
摘要: 题意:把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。分析:dp,我们认为每个盘子所放的苹果数组成的数列是降序的,讨论最后一个盘子放不放苹果,若放则前面每个盘子都放,方法数相当于把每盘方一个之后剩下的m-n个苹果往n个盘子里放,若不放则相当于把m个苹果放入n-1个盘子。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace s 阅读全文
posted @ 2011-06-16 18:02 undefined2024 阅读(461) 评论(0) 推荐(0)
摘要: dpView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 1005struct Plat{ int l, r, h, lt, rt;} plat[maxn];int n, m, cx, cy;bool operator <(const Plat &a, const Plat &b){ return a 阅读全文
posted @ 2011-06-16 13:13 undefined2024 阅读(393) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); getchar(); while (t--) { int x1 = getchar() - & 阅读全文
posted @ 2011-06-16 12:06 undefined2024 阅读(240) 评论(0) 推荐(0)