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. PCB MS SQL 标量函数(CLR) 实现DataTable转HTML的方法

    一.准备需转为HMLT字符串的DataTable数据 在数据库中执行一段SQL返回的数据 需转换后的HTML的文本 <html ><head></head>< ...

  2. js返回上一层

    Javascript 返回上一页 1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). wind ...

  3. SpringBoot 热部署 + IDEA

    1.使用Spring-Boot-Devtools实现热加载(这种方式会自动重启) devtools的原理: 深层原理是使用了两个ClassLoader,一个Classloader加载那些不会改变的类( ...

  4. QT 制作串口调试小助手----(小白篇)

    一.成品图展示 简介:因zigbee实验,制作一个相对简易版的上位机,接收来自zigbee无线传感采集的温湿度.光照等数据. 并且将数据部分描绘成实时动态折线统计图. 二.主要功能介绍 主要使用QT自 ...

  5. vagrant使用centos的环境安装..

    vagrant这货挺好用的..简要就是, 下好virtualbox, vagrant, 然后下个你需要的box. 然后vagrant box add boxname boxpath就行. 然后在合适的 ...

  6. CSS——行内元素的margin与padding

    行内元素: 1.margin:0 20px:只可以定义左右. 2.pading:20px 20px 20px 20px:上下左右都有效 例如span: <!DOCTYPE html> &l ...

  7. SQL server 2005中无法新建作用(Job)的问题

    1.在使用sqlserver2005创建作业时,创建不了,提示 无法将类型为“Microsoft.SqlServer.Management.Smo.SimpleObjectKey”的对象强制转换为类型 ...

  8. 一个有趣的 ”Validation of viewstate MAC failed” 错误的发现和解决

    在ASP.NET里面,View State使用较为广泛.它作为一个隐藏字段,可以帮助服务端”记住“客户端的改变,这样客户端 收到服务器对PostBack的响应后,仍然可以展现在PostBack之前设定 ...

  9. java_File对象

    package File; import java.io.File; import java.io.IOException; public class file { public static voi ...

  10. ionic4封装样式原理

    查看文档: https://www.cnblogs.com/WhiteCusp/p/4342502.html https://www.jianshu.com/p/bb291f9678e1 https: ...