- 博客(28)
- 资源 (1)
- 收藏
- 关注
原创 hdu 1286 找新朋友(欧拉函数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1286//欧拉函数:设m是衣蛾正整数,则0-(m-1)之间与m互素的整数的个数//m=p1^a1*p1^a2~~pi^ai~~pk^pk;//p1~~pk都为素数,则欧拉函数φ(m)=m*(1-1/p1)*(1-1/p2)~(1-1/pi)~(1-1/pk) [相乘]#include#i
2013-11-30 19:52:20 472
原创 hdu 1215 七夕节
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1215#include#include#includeusing namespace std;int prim[500010];void Prim()//帅法求因子和{ int i,j; for(i=1;i<=250000;i++) {
2013-11-30 15:19:33 406
原创 HDU 1164 Eddy's research I
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1164#include#includeint prim[66000];void check(){ int i,j,p=1; for(i=2;i<=32770;i++) { for(j=2*i;j<=65540;j+=i) {
2013-11-30 10:46:29 429
原创 hdu 1593 find a way to escape
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1593//oo68先找个使自己角速度等于elnil角速度的同心圆,并且oo68与elnil在一条向上且不在远的一侧,#include#define PI 3.1415926int main(){ double r,R,v1,v2,t1,t2; while (scanf("
2013-11-29 19:00:46 375
转载 HDU 1501 Zipper
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1501#include#include#include#define MAX 210using namespace std;char a[MAX], b[MAX], c[2*MAX];int dp[MAX][MAX];int main(){ int i,j,t=1,Case,
2013-11-28 21:25:21 361
原创 HDU 1421 搬寝室
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1421这道题与http://acm.hdu.edu.cn/showproblem.php?pid=1500一样#include#include#includeusing namespace std;int dp[2010][2010];int s[2010];int area(int x
2013-11-28 09:33:22 470
转载 hdu 1500
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1500#include#includeusing namespace std;int dp[5001][1001],s[5005];int area(int t){return t*t;}int main(){ int i,j,Case,k,n; scanf("%d"
2013-11-27 21:30:40 522
原创 HDU 1272 小希的迷宫
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272#include#includeint p[100005],flag,sign[100005];//数组开在主函数里,这个代码就超时了int find(int x){return p[x]==x?x:p[x]=find(p[x]);}void father (int x,int y)
2013-11-27 15:15:20 395
原创 HDU 1213 How Many Tables
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1213代码1:#includeint n,m,p[1005];int find(int x) {return p[x]==x?x:find(p[x]);}int father (int x,int y){ int xx=find(x);int yy=find(y);
2013-11-27 08:57:07 415
原创 hdu 1072 Nightmare
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1072//这里不能标记路径,所以不能深搜,用深搜会成死循环//广搜,无线搜索下去,当收到的时候,一定是个最短的距离,#include#include#includeusing namespace std;int map[8][8];int n,m,sx,sy,tx,ty;int dx
2013-11-26 11:32:32 350
原创 hdu 1249 三角形
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1249//可以画一个圆,圆里放一个内正三角形。当放入第二个时,//我们就把它转化为把已有的第一个三角形围着同心轴稍微往右转一点点(向左转一样的),//那么,第二个三角形的每一条边都会与第一个三角形的其中两条边相交,//这样就可得3*1*2+2个区域,3表示3条边,//1表示第二个三角形的每一
2013-11-25 10:51:56 330
原创 hdu 1292 "下沙野骆驼"ACM夏令营
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1292#includeint main() { int t,n,i,j; __int64 a[26][26]; a[1][1]=1; a[1][0]=0; for (i=2;i<=25;i++)//i代表现在总共几个人分组 { a
2013-11-22 21:53:35 499
原创 hdu 1397 Goldbach's Conjecture
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1397#include#includeint vis[32800];int check1(int n){ int i; for(i=2;i*i<=n;i++) { if(n%i==0) return 0; } retur
2013-11-22 15:33:41 502
原创 hdu 1016 Prime Ring Problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016#include#include#include#includeusing namespace std;int dp[30],vis[100],N;int check(int x){ for(int i=2;i<x;i++) if(x%i==0) ret
2013-11-20 09:18:06 600
原创 hdu 1078 FatMouse and Cheese(记忆化搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1078#include#include#includeusing namespace std;int dp[110][110],s[110][110];int n,k;int dx[4]={0,-1,0,1};int dy[4]={1,0,-1,0};int dfs(int x,in
2013-11-17 20:37:07 392
原创 hdu 2164 Rock, Paper, or Scissors?
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2164#includeusing namespace std;int judge(int n){ int player1=0,player2=0,i; char P,PP; for(i=0;i<n;i++) { cin>>P>>PP;
2013-11-08 15:16:23 509
原创 hdu 2163 Palindromes
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2163#include#includeusing namespace std;int judge(char *s){ int i,len=strlen(s),flag=1,j; for(i=0,j=len-1;i<=j;i++,j--) { if(
2013-11-08 14:47:40 679
原创 hdu 2161 Primes
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2161#include#includeusing namespace std;int fun(int n){ int i,flag=1; for(i=2;i<=sqrt(n);i++) { if(n%i==0) flag=0; if
2013-11-08 14:01:25 494
原创 hdu 2160 母猪的故事
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2160#includeusing namespace std;int Pig( int n ){ if ( n == 1 ) return 1 ; else if( n == 2 ) return 2; else re
2013-11-08 13:37:45 609
原创 hdu 2190 悼念512汶川大地震遇难同胞——重建希望小学
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2190int main(){ int T,dp[35],i; dp[1]=1;dp[2]=3; for(i=3;i<=30;i++) dp[i]=dp[i-1]+dp[i-2]*2; //dp[i-1]就是多1米全部放长为1米的方块
2013-11-07 13:09:16 659
原创 hdu 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2191#include#include#includeusing namespace std;int dp[102],W;int p[102],w[102],num[102];void pack(int cost,int weight){ for(int i=W;i>
2013-11-06 09:25:44 413
原创 hdu 2188 悼念512汶川大地震遇难同胞——选拔志愿者
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2188#includeint main(){ int T; scanf("%d",&T); while(T--) { int n,m; scanf("%d%d",&n,&m); if(n%(m+1)) prin
2013-11-05 17:06:09 391
原创 hdu 2186 悼念512汶川大地震遇难同胞——一定要记住我爱你(水题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2186#includeint main(){ int T; scanf("%d",&T); while(T--) { int n,num1,num2,num3,num4; scanf("%d",&n); num1
2013-11-05 15:26:59 658
原创 hdu 1279 验证角谷猜想
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1279#includeint main(){ int N,n,i,num; scanf("%d",&N); while(N--) { scanf("%d",&n); num=0;
2013-11-04 17:02:23 583
原创 hdu 1287 破译密码
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1287#includeint main(){ int i,j,a[1002],N; char s; while(scanf("%d",&N)!=EOF) { for(i=0;i<N;i++) scanf("%d",&a[i]);
2013-11-04 16:42:43 506
原创 hdu 1228 A + B()
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1228 #include#includeint main(){ char a[30]; while(1) { gets(a); int i,j,len=strlen(a),A=0,B=0; for(i=0;i<le
2013-11-04 16:11:38 450
原创 hdu 1251 统计难题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251#include#include#include#define LED struct nodestruct node{ int n; struct node *next[26];};struct node *root;struct node *build()
2013-11-04 13:11:34 391
原创 hdu 1032 The 3n + 1 problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1032#includeint main(){ int max=-1,nn,N,M,n,m,i,j,count; while(~scanf("%d%d",&N,&M)) { n=N,m=M; if(n>m){i=n;n=m;m=i;}
2013-11-04 13:08:51 465
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人