摘要: #include<iostream>#include<algorithm>using namespace std;int i,n,j,p,w,a[1000000],ans[1000000];int main(){ while(scanf("%d",&n)!=EOF) { p=(n+1)/2; memset(ans,0,sizeof(ans)); for(j=0;j<n;j++) scanf("%d",&a[j]); for(i=0;i<n;i++) { ans[a[i]]++; if(ans[a[i]] 阅读全文
posted @ 2013-04-30 18:01 galaxy77 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 搜索http://acm.hdu.edu.cn/showproblem.php?pid=1584枚举每张未移动的牌移动到后面的第一张未移动的牌上去 比如要移动1 而 2 3 4 都移动过了 就把1移动到 5上去 因为 2 3 4 一定都移动到了 5上面#include<iostream>#include<string.h>#include<math.h>using namespace std;int a[12],vis[12],min1;void dfs(int cur,int temp){ int i,j; if(temp>=min1) return 阅读全文
posted @ 2013-04-30 17:56 galaxy77 阅读(232) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1421d[n][m] : 在前n个物品里选m对的最小疲劳当地n件不选时 d[n][m]=d[n-1][m]当第n件选是 第n件一定是与第n-1件一起组成一对 d[n][m]=d[n-2][m-1]+(a[n]-a[n-1])^2所以动态转移方程为d[i][j]=min1(d[i-1][j],d[i-2][j-1]+(a[i-1]-a[i])*(a[i-1]-a[i]));#include<iostream>#include<string.h>#include<math.h> 阅读全文
posted @ 2013-04-30 17:36 galaxy77 阅读(131) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1069#include<stdio.h>#include<stdlib.h>typedef struct abc{int x,y,z;} abc;abc a[100];//定义结构体,里边分别存,长宽高;int k;int cmp( const void *a,const void *b){abc *c,*d;c=(abc *)a;d=(abc *)b;if(c->x!=d->x) return c->x-d->x;else return c->y-d-& 阅读全文
posted @ 2013-04-30 17:22 galaxy77 阅读(166) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4207两个数都不会超过六位数 所以可以直接用64位int 不会溢出只要注意输出格式 就好了#include<iostream>#include<string.h>using namespace std;__int64 a;int max1;int count(__int64 x){ int t=0; while(x) { x/=10; t++; } return t;}void solve(int temp,int c,int p){ __int64 v,i,ans; if(c==-1 阅读全文
posted @ 2013-04-30 13:08 galaxy77 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<math.h>#define M 99999999void main(){ int i,n,x,min,f[100]; f[1]=1; f[2]=3; for(i=3;i<=65;i++) { min=M; for(x=1;x<i;x++) if(2*f[x]+pow(2,i-x)-1<min) min=2*f[x]+(int)pow(2,i-x)-1; f[i]=min; } while(scanf("%d",&n)!=EOF) printf("%d\n&quo 阅读全文
posted @ 2013-04-30 12:58 galaxy77 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<math.h>using namespace std;int main(){ int i,n; __int64 f[100]; f[0]=0;f[1]=2; for(i=2;i<=35;i++) f[i]=f[i-1]*3+2; while(scanf("%d",&n)!=EOF) printf("%I64d\n",f[n]); return 0;} 阅读全文
posted @ 2013-04-30 12:57 galaxy77 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;int main(){int a[22]={0,1};int i,n;for(i=2;i<=20;i++) a[i]=3*a[i-1]+1;scanf("%d",&n);while(n--){ scanf("%d",&i); printf("%d\n",2*a[i-1]+2);}return 0;} 阅读全文
posted @ 2013-04-30 12:56 galaxy77 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 有规律64个盘子的话 第64个移动2^0次 第63个移动2^1次 第62个移动2^2次。。。。。类推#include<iostream>using namespace std;__int64 f[65][65];int main(){ int i,j,m,n; f[1][1]=1; for(i=2;i<=64;i++) { f[i][i]=1; for(j=i-1;j>0;j--) f[i][j]=2*f[i][j+1]; } scanf("%d",&n); while(n--) { scanf("%d%d",&i 阅读全文
posted @ 2013-04-30 12:55 galaxy77 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #include"stdio.h" int main( ) { __int64 num[31]={1}; int i,t,n; for(i=1;i<=30;i++) num[i]=num[i-1]*3; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%I64d\n",num[n]); } return 0;}输出pow(3,n) 测试了是对的 提交上去wa 。。 不懂为什么 阅读全文
posted @ 2013-04-30 12:51 galaxy77 阅读(135) 评论(2) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1060如 :n=87455时,a=4,b=0.941784644.有规律.10^a=10000 10^b=8.7455.任何一个数字都可以表示成10^(a+b) a>=1,b<1n*n=10^(a+b)两边对10取对数 n*log10(n)=a+b;a是整数部分 b是小数部分由于10的整数次幂首位均为1,则仅需考虑Nlog10(N)的结果的小数部分即可 b=n*log10(n)-floor(n*log10(n)) pow(10,b) 得到10^b 其结果大于1小于10 取其整数部分 即可#incl 阅读全文
posted @ 2013-04-30 12:47 galaxy77 阅读(159) 评论(0) 推荐(0) 编辑