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
step 1:01
step 2:1001
step 3:0110 1001
step 4:1001 0110 0110 1001
step 5:0110 1001 1001 0110 1001 0110 0110 1001
 /*找规律,0 1 1 3 5 11 21 43 85,找出递推关系f(n)=2*f(n-2)+f(n-1),*/
#include<stdio.h>
int a[][]={{},{},{},{}};
int b[]={};
int calc()/*由于n可以取到1000,2^1000超出long long,必须要用数组按位存储,所以考大数*/
{
int i=;
for(i=;i<;i++)
{
int c,j;
for(c=,j=;j<;j++)/*利用b数组存储2*f(n-2)*/
{
b[j]=b[j]*+c;/*c为余数*/
c=b[j]/;
b[j]=b[j]%;
}
for(c=,j=;j<;j++)/* 2*f(n-2)+f(n-1) */
{
a[i][j]=b[j]+a[i-][j]+c;
c=a[i][j]/;
a[i][j]=a[i][j]%;
}
}
}
int main()
{
int n,i,k=;
calc();
while(~scanf("%d",&n))
{
if(n==)
printf("");
else
{
k=;
for(i=;i>=;i--)
{
if(a[n][i]||k)
{
printf("%d",a[n][i]);
k=;
}
}
}
printf("\n");
}
}

Computer Transformation(hdoj 1041)的更多相关文章

  1. HDU 1041 Computer Transformation (简单大数)

    Computer Transformation http://acm.hdu.edu.cn/showproblem.php?pid=1041 Problem Description A sequenc ...

  2. Computer Transformation(规律,大数打表)

    Computer Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...

  3. hdu_1041(Computer Transformation) 大数加法模板+找规律

    Computer Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...

  4. (大数)Computer Transformation hdu1041

    Computer Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...

  5. Computer Transformation(简单数学题+大数)

    H - Computer Transformation Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d &am ...

  6. HDU 1041 Computer Transformation

    这道题目的意思是:一开始有一个数字 1 ,在接下来的时间中,计算机会按照如下规则进行扩展:                0 –> 1 0                1 –> 0 1 ...

  7. HDU 1041 Computer Transformation(找规律加大数乘)

    主要还是找规律,然后大数相乘 #include<stdio.h> #include<string.h> #include<math.h> #include<t ...

  8. HDU 1041 Computer Transformation 数学DP题解

    本题假设编程是使用DP思想直接打表就能够了. 假设是找规律就须要数学思维了. 规律就是看这些连续的0是从哪里来的. 我找到的规律是:1经过两次裂变之后就会产生一个00: 00经过两次裂变之后也会产生新 ...

  9. HDOJ-1041 Computer Transformation(找规律+大数运算)

    http://acm.hdu.edu.cn/showproblem.php?pid=1041 有一个初始只有一个1的串 每次都按①0 -> 10;②1 -> 01;这两条规则进行替换 形如 ...

随机推荐

  1. URL锚点定位

    我们都知道<a>标签中的url属性有三种值: 绝对 URL - 指向另一个站点(比如 href="http://www.example.com/index.htm") ...

  2. python笔记之itertools模块

    python笔记之itertools模块 itertools模块包含创建有效迭代器的函数,可以用各种方式对数据进行循环操作,此模块中的所有函数返回的迭代器都可以与for循环语句以及其他包含迭代器(如生 ...

  3. webService设置超时时间

    在客户端配置文件中设置: <bindings>      <basicHttpBinding>        <binding name="UrlCrawler ...

  4. LeetCode_Longest Palindromic Substring

    Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...

  5. SQL Server 2008空间数据应用系列十:使用存储过程生成GeoRSS聚合空间信息

    原文:SQL Server 2008空间数据应用系列十:使用存储过程生成GeoRSS聚合空间信息 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2 ...

  6. Memcached安装,操作,用C#操作

    本文来自:http://li19910722.blog.163.com/blog/static/136856822201406103313163/ 1:安装 下载Memcache:http://cod ...

  7. hdu 4627 水数学题

    最小公倍数最大,也就是尽量让2个数互质,所以把n除以2 从中间向两边找就够了,自己写几组数据就能发现规律. 注意longlong存 #include<cstdio> #include< ...

  8. RMAN传输表空间迁移数据

    实验环境: 源数据库:oracle 10g(Release 10.2.0.1.0) 目标数据库:oracle 10g(Release 10.2.0.1.0) 待传输的表空间:TEST 1.在tes ...

  9. AliCTF 2016

    上上周参加了阿里的CTF,靠着最后绝杀队伍有幸拿到了国内第一名,也顺利进入了XCTF Final.把自己做的几个题简单写了下,发出来也算个总结吧. PWN-FB 经典的null byte overfl ...

  10. Android应用自动更新功能的实现!!!

    自动更新功能的实现原理,就是我们事先和后台协商好一个接口,我们在应用的主Activity里,去访问这个接口,如果需要更新,后台会返回一些数据(比如,提示语:最新版本的url等).然后我们给出提示框,用 ...