博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDUOJ-----Computer Transformation
阅读量:4350 次
发布时间:2019-06-07

本文共 1700 字,大约阅读时间需要 5 分钟。

 

 

 

Computer Transformation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4842    Accepted Submission(s): 1769
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?
 
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
2
3
 
Sample Output
1
1
做这道题,纯粹是一道大数的题,当然你需要推导出这个公式f[n]=f[n-1]+2*f[n-2];
1 #include
2 const int maxn=1000; 3 int arr[maxn+1][305]={
0}; 4 int len=1; 5 void LargeNum() 6 { 7 arr[1][0]=1; 8 for(int i=2;i<=maxn;i++) 9 {10 int c=0;11 for(int j=0;j
9)15 len++;16 c=arr[i][j]/10;17 arr[i][j]%=10;18 }19 }20 21 }22 int main( void )23 { 24 int n,i;25 LargeNum();26 while(scanf("%d",&n)==1)27 {28 if(n==1)puts("0");29 else30 {31 for(i=len;arr[n-1][i]==0;i--);32 for(int j=i;j>=0;j--)33 printf("%d",arr[n-1][j]);34 puts("");35 }36 }37 return 0;38 }
View Code

转载于:https://www.cnblogs.com/gongxijun/p/3199989.html

你可能感兴趣的文章
HDUOJ-----2838Cow Sorting(组合树状数组)
查看>>
自定义控件之---抽屉式弹窗控件.
查看>>
一款纯css3实现的机器人看书动画效果
查看>>
加班与效率
查看>>
轻量级Modal模态框插件cta.js
查看>>
MyEclipse下SpringBoot+JSP整合过程及踩坑
查看>>
重定向和管道
查看>>
实验五
查看>>
STL学习笔记(第二章 C++及其标准程序库简介)
查看>>
Operator_countByValue
查看>>
Java 日期往后推迟n天
查看>>
Web应用漏洞评估工具Paros
查看>>
Git 和 Github 使用指南
查看>>
20180925-4 单元测试
查看>>
mysql的数据存储
查看>>
[转载] Activiti Tenant Id 字段释疑
查看>>
[Java 8] (8) Lambda表达式对递归的优化(上) - 使用尾递归 .
查看>>
SQL Server-聚焦移除Bookmark Lookup、RID Lookup、Key Lookup提高SQL查询性能
查看>>
最小权限的挑战
查看>>
jquery 视觉特效(水平滚动图片)
查看>>