摘要: hdu 4548 美素数 用线性筛法筛选出10^6的素数,然后预处理统计下.. O(1)就能得到结果了.#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;const int N = (int)1e6+10;bool vis[N];int p[N], sum[N];void GetPrime(){ memset(vis,0,sizeof(0)); vis[1] = 1; int cnt = 0; for(int i = 2 阅读全文
posted @ 2013-05-19 16:31 yefeng1627 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 弱到一定程度了... 不过还好.又涨经值和姿势了.....hdu 4551 生日猜猜猜 月份和日期都比较小, (12,31) 果断暴力, 然后判定下当前月份和天数是否合法.#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;int day[2][13] = { {0,31,28,31,30,31,30,31,31,30,31,30,31 } ,{0,31,29,31,30,31,30,31,31,30,31,30,31 }};int gcd(int a,int b){ r 阅读全文
posted @ 2013-05-19 14:34 yefeng1627 阅读(203) 评论(0) 推荐(0) 编辑

Launch CodeCogs Equation Editor