上一页 1 ··· 16 17 18 19 20
摘要: #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 阅读(158) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20