-
HDU 1848 Fibonacci again and again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1848组合博弈 sg值我的代码 1 #include <stdio.h> 2 #include <string.h> 3 int main() 4 { 5 const int N=1001,M=17; 6 const char name[2][10]={"Nacci","Fibo"}; 7 int f[M]={1,1}; 8 for (int i=2;i<M;i++) f[i]=f[i-1]+f[i-2]; 9 int a[N]={0},v
阅读全文
-
HDU 1050 Moving Tables
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1050贪心写的。写完后百度发现直接记录每个走廊出现的次数就行了,巧妙的思路,没想到。View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 using namespace std; 6 const int N=250; 7 struct corridor 8 { 9 int b,e;10 }a[N];11 int s[N];12
阅读全文
-
HDU 2102 A计划
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2102BFS我的代码 1 #include <cstdio> 2 #include <queue> 3 using namespace std; 4 const int dx[4]={0,1,0,-1}; 5 const int dy[4]={1,0,-1,0}; 6 char maze[2][15][15]; 7 bool vis[2][15][15]; 8 int n,m,t,dis[2][15][15]; 9 queue<int> q;10 int bfs(int x
阅读全文
-
HDU 1171 Big Event in HDU
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1171多重背包我的代码 1 #include <stdio.h> 2 #include <string.h> 3 const int N=250010; 4 int f[N],v[60],c[60]; 5 int main() 6 { 7 int n,i,j,k,s,ss,cc; 8 while (scanf("%d",&n) && n>=0) 9 {10 memset(f,0,sizeof(f)); f[0]=1;11 ss=0;12
阅读全文
-
HDU 1010 Tempter of the Bone
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1010DFS我的代码 1 #include <stdio.h> 2 #include <stdlib.h> 3 const int dx[]={0,1,0,-1}; 4 const int dy[]={1,0,-1,0}; 5 int n,m,t,sx,sy,ex,ey,ans; 6 char maze[10][10]; 7 void dfs(int x,int y,int s) 8 { 9 if (ans) return;10 if (abs(ex-x)+abs(ey-y)+s>
阅读全文
-
HDU 2899 Strange fuction
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2899三分法我的代码 1 #include <stdio.h> 2 #include <math.h> 3 const double eps=1e-8; 4 double y; 5 double f(double x) 6 { 7 return 6*pow(x,7)+8*pow(x,6)+7*x*x*x+5*x*x-y*x; 8 } 9 int main()10 {11 int T;12 double l,r,ml,mr;13 scanf("%d",&T);
阅读全文
-
HDU 1969 Pie
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1969二分法我的代码 1 #include <stdio.h> 2 #include <math.h> 3 const double eps=1e-6; 4 const double pi=acos(-1.0); 5 const int N=10010; 6 double a[N]; 7 int n,f; 8 int ok(double m) 9 {10 int i,cnt=0;11 for (i=1;i<=n;i++)12 cnt+=(int)(a[i]/m);13 ...
阅读全文
-
HDU 1102 Constructing Roads
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1102并查集我的代码 1 #include <stdio.h> 2 #include <stdlib.h> 3 const int N=110; 4 struct edge 5 { 6 int u,v,w; 7 }e[N*N]; 8 int a[N][N],set[N]; 9 int cmp(const void *a,const void *b)10 {11 return ((edge*)a)->w - ((edge*)b)->w;12 }13 int find(int
阅读全文
-
HDU 2648 Shopping
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2648我的代码 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 struct shop 5 { 6 char name[50]; 7 int p; 8 }a[10010]; 9 const char like[]="memory";10 int n;11 int cmp1(const void *a,const void *b)12 {13 return strcmp(((s
阅读全文
-
HDU 2289 Cup
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2289我的代码 1 #include <stdio.h> 2 #include <math.h> 3 double r1,r2,h,v; 4 const double pi=acos(-1.0),esp=1e-9; 5 double f(double x) 6 { 7 double r=(r2-r1)*x/h+r1; 8 return (r1*r1+r*r+r1*r)*pi*x/3; 9 }10 int main()11 {12 int T;13 double l,r,m;14...
阅读全文
-
HDU 2141 Can you find it?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2141先把A和B合并为1个序列,再用二分查找我的代码 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 const int N=510; 5 int a[N],b[N],c[N],d[N*N]; 6 int find(int x,int *a,int l,int r) 7 { 8 int m; 9 while (l<r)10 {11 m=(l+r)/2;12 if (x...
阅读全文
-
HDU 2757 Ocean Currents
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2757BFS+优先队列我的代码 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 const int N=1010,INF=10000; 6 struct sta 7 { 8 int x,y,d; 9 };10 struct qcmp11 {12 bool operator() (const sta a,const sta b)13 {14 retur..
阅读全文
-
HDU 1026 Ignatius and the Princess I
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1026BFS+优先队列我的代码 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 typedef pair<int,int> pii; 6 priority_queue<pii,vector<pii>,greater<pii> >q; 7 const int N=110; 8 const int dx[4]=
阅读全文
-
HDU ACM Doing Homework again
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心先安排分数大的作业,设它的期限为t,若第t天没被安排,则安排在第t天,否则往前找空闲时间,即t-1,t-2,t-3......1,直到找到第i天空闲,则安排在第i天,若前t天都被安排了,没有空闲时间,则这个作业无法完成另外当t>n时,可令t=n,n天足够完成所有作业了我的代码 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 struct work 5 { 6 int s,t
阅读全文
-
HDU 2104 hide handkerchief
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2104最大公约数=1是YESView Code 1 #include <stdio.h> 2 int gcd(int x,int y) 3 { 4 return y==0?x:gcd(y,x%y); 5 } 6 int main() 7 { 8 int m,n; 9 while (scanf("%d%d",&m,&n) && m!=-1 && n!=-1)10 if (gcd(m,n)>1) printf("POO
阅读全文
-
杭电ACM3033-I love sneakers!
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3033I love sneakers!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1107Accepted Submission(s): 455Problem DescriptionAfter months of hard working, Iserlohn finally wins awesome amount of scholarship. As a
阅读全文
-
杭电ACM1712-ACboy needs your help
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1712ACboy needs your helpTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 901Accepted Submission(s): 450Problem DescriptionACboy has N courses this term, and he plans to spend at most M days on study.Of cour
阅读全文
-
杭电ACM2159-FATE
摘要:http://www.cnblogs.com/yangcl/admin/EditPosts.aspx?opt=1FATETime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2198Accepted Submission(s): 930Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升
阅读全文
-
杭电ACM2191-悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
摘要:http://www.cnblogs.com/yangcl/admin/EditPosts.aspx?opt=1悼念512汶川大地震遇难同胞——珍惜现在,感恩生活Time Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4736Accepted Submission(s): 1940Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米
阅读全文
-
杭电ACM1114-Piggy-Bank
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1114Piggy-BankTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3348Accepted Submission(s): 1665Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obt
阅读全文
|