Computer Transformation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5065    Accepted Submission(s): 1850

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
 
Source
 
 
 #include <stdio.h>
#include <string.h> int an1[],an2[];
char s[][]; int main()
{
int i,j,k,len,t,n,aa;
memset(an1,,sizeof(an1));
memset(an2,,sizeof(an2));
memset(s,,sizeof(s));
strcpy(s[],"");
strcpy(s[],"");
an1[]=;
len=;t=;
for(i=;i<=;i++)
{
t=;
for(j=;j<=len;j++)
{
an2[j]=an1[j]*+t;
if(an2[j]>)
{
an2[j]-=;
t=;
}
else
t=;
if(j==len&&t==)
len+=;
an1[j]=an2[j];
}
if(i&)
{an1[]=an2[]-=;}
else
{an1[]=an2[]+=;}
for(k=,aa=j-;aa>=;aa--)
{
an1[aa]=an2[aa];
s[i][k++]=an2[aa]+'';
}
}
while(scanf("%d",&n)!=EOF)
{
printf("%s\n",s[n]);
}
return ;
}
//大数,找规律

找规律,大数问题

 

hdu_1041_Computer Transformation_201311051648的更多相关文章

随机推荐

  1. cocos creator学习

    2019-05-30 22:23:27 按照前一节我发的教程做,大概了解了Cocos creator的基本布局 但是你发现你不好写代码(感觉视频没有提) 需要下载VS code软件,在其上进行编辑,教 ...

  2. centos6.6安装redis

    .安装仓库 yum install epel-release -y2.安装redis yum install redis -y3.程序文件说明 安装完毕后有以下几个文件位于/usr/bin目录: re ...

  3. mina2 笔记

    http://www.iteye.com/topic/1112123 http://dongxuan.iteye.com/blog/901689 http://scholers.iteye.com/b ...

  4. [转]Linux下paste命令详解

    转自:http://blog.csdn.net/andy572633/article/details/7214126 paste单词意思是粘贴.该命令主要用来将多个文件的内容合并,与cut命令完成的功 ...

  5. [ SHOI 2012 ] 随机树

    \(\\\) \(Description\) 开始有一棵只有一个根节点的树.每次随机选择一个叶子节点,为他添上左右子节点,求: 生成一棵有\(N\)个叶节点的树,所有叶节点平均高度的期望. 生成一棵有 ...

  6. Java——Spring注解

    Spring常用注解使用注解来构造IoC容器用注解来向Spring容器注册Bean.需要在applicationContext.xml中注册<context:component-scan bas ...

  7. asp.net——登录界面

    题目: 在页面中放入两个TextBox分别用于输入用户名和密码,一个显示文字用的Label,一个提交按钮Button.点击按钮提交用户名和密码,如果用户名都密码正确(比如用户名admin 密码abc1 ...

  8. 2017-5新版ionic3.1 新命令及一些常用命令

    ionic3.1的新命令: # ionic cordova --help //== 查看命令 # ionic cordova resources // 其中 icon.png (1024*1024) ...

  9. 挂载硬盘,提示 mount: unknown filesystem type 'LVM2_member'的解决方案

    问题现象:由于重装linux,并且加了固态硬盘,直接将系统装在固态硬盘中.启动服务器的时候, 便看不到原来机械硬盘的挂载目录了,不知如何访问机械硬盘了.直接用命令 mount /dev/sda3 /s ...

  10. C# 配置文件ini操作类

    // [ DllImport ( "kernel32" ) ] //private static extern long WritePrivateProfileString ( s ...