HDU 1041 Computer Transformation 大数递推
来源:互联网 发布:淘宝店铺关闭重新开 编辑:程序博客网 时间:2024/04/27 14:21
Computer Transformation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5787 Accepted Submission(s): 2090
Problem Description
A sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simultaneously tranforms each digit 0 into the sequence 1 0 and each digit 1 into the sequence 0 1. So, after the first time step, the sequence 0 1 is obtained; after the second, the sequence 1 0 0 1, after the third, the sequence 0 1 1 0 1 0 0 1 and so on.
How many pairs of consequitive zeroes will appear in the sequence after n steps?
How many pairs of consequitive zeroes will appear in the sequence after n steps?
Input
Every input line contains one natural number n (0 < n ≤1000).
Output
For each input n print the number of consecutive zeroes pairs that will appear in the sequence after n steps.
Sample Input
23
Sample Output
11
/*要学会分析题目啊。。。。。00的产生必然由n-1组的01产生,即00的个数等于n-1组01的个数。n-1组01的产生有两个来源。1).由n-2组的12).由n-2组的00变幻1010,其中一个00只能产生一个01.这个就是要求的n-2连续的个数 可以推出第n组00的个数dp[n]=dp[n-2]+第n-2组1的个数(2^((n-2)-1)); 发现还要用大数 */#include<iostream>#include<cstring>using namespace std;int dp[1002][500];//因为两个长度 比较麻烦 直接500 不记长度 int p[500];int main(){ int n,i,j,z,t; memset(p,0,sizeof(p)); memset(dp,0,sizeof(dp)); dp[1][1]=0; dp[2][1]=1; dp[3][1]=1; p[1]=1; for(i=4;i<1001;i++) { for(j=1;j<500;j++)//处理2的多次方 p[j]=p[j]*2; z=0; for(j=1;j<500;j++) { t=p[j]+z; z=t/10; p[j]=t%10; } for(j=1;j<500;j++)//处理递推方程 dp[i][j]=dp[i-2][j]+p[j]; z=0; for(j=1;j<500;j++) { t=dp[i][j]+z; z=t/10; dp[i][j]=t%10; } } while(cin>>n) { i=499; while(dp[n][i]==0) i--; for(;i>=1;i--) printf("%d",dp[n][i]); if(n!=1) printf("\n"); else printf("0\n"); } return 0;}
0 0
- HDU 1041 Computer Transformation 大数递推
- hdu 1041 Computer Transformation(大数递推)
- HDU-1041-Computer Transformation,大数递推,水过~~
- hdu 1041 Computer Transformation(递推+大整数模板*)
- hdu 1041 Computer Transformation(规律+大数)
- 递推-hdu1041 Computer Transformation
- HDU ACM 1041Computer Transformation(大数模拟+找规律)
- HDU-1041-Computer Transformation(规律题 && 大数题)
- HDU 1041 Computer Transformation
- HDU-1041-Computer Transformation
- hdu 1041 Computer Transformation
- hdu 1041 Computer Transformation
- HDU Computer Transformation 1041
- HDOJ HDU 1041 Computer Transformation
- POJ Computer Transformation 递推 + 高精度
- poj2680 Computer Transformation----简单的递推
- hdu 1041(Computer Transformation)(找规律,二维数组大数)
- HDU 1041.Computer Transformation【递推+高精】【12月27】
- UVALIVE 2519 Radar Installation 区间选点问题
- iframe与form结合,进行局部刷新
- 《剑魂之刃》游戏破解
- C++智能指针--shared_ptr
- 每个开发者都应该有一款自己的App
- HDU 1041 Computer Transformation 大数递推
- 设计模式之建造者模式 c++实现和详细分析
- C++智能指针--unique_ptr
- 一道简单的C程序--考考你
- uva 1434 - YAPTCHA(数论)
- acm-最短路 畅通工程续 (hdu 1874)
- HDOJ 1097 A hard puzzle 阶乘末尾数找规律
- 大数据导出报错
- 数据结构(scheme) -- 抽象数据类型(ADT) -- 堆