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. 湖南集训day8

    难度:☆☆☆☆☆☆☆ /* 可以先考虑一维,可知 模k意义下相同的前缀和任意两个相减都是k的倍数 问题等价于统计前缀何种模k相同的数的对数. 多维的时候二维前缀和,压行或者压列,n^3可以解决. */ ...

  2. 面试说熟练掌握各种MQ?那你先看看这道题,面试官必问!

    写在前面 我们知道,目前市面上的MQ包括Kafka.RabbitMQ.ZeroMQ.RocketMQ等等. 那么他们之间究竟有什么本质区别,分别适用于什么场景呢? 上述抛出的问题,同样在不少公司的Ja ...

  3. ACM_最短网络(最小生成树)

    Problem Description: Farmer John has been elected mayor of his town! One of his campaign promises wa ...

  4. MVC系列学习(六)-Razor语法

    注:本次代码加了样式,样式如下 <style>     div {         border: 1px solid red;         margin: 10px auto;    ...

  5. XML解析-Dom4j的DOM解析方式更新XML

    Dom4j工具,是非官方的,不在jdk中. 使用步骤: 1)导入dom4j的核心包. dom4j-1.6.1.jar 2)编写Dom4j读取xml文件的代码 1.更新XML 1.1.写出内容到xml文 ...

  6. eclipse 安装svn插件记录

    每个人都有自己喜欢的和习惯的一套开发环境,其中对于喜欢用eclipse的同学来说.subclipse插件可以说是必不可少的插件了. 他的安装有两种方法,一种是在线安装.然而这种安装实在是太慢了,无法忍 ...

  7. P1968 美元汇率

    题目背景 此处省略maxint+1个数 题目描述 在以后的若干天里戴维将学习美元与德国马克的汇率.编写程序帮助戴维何时应买或卖马克或美元,使他从100美元开始,最后能获得最高可能的价值. 输入输出格式 ...

  8. Mac sierra下 wget安装

    本文由@ray 出品,转载请注明出处.  文章链接:http://www.cnblogs.com/wolfray/p/8040699.html 没有Wget的日子是非常难过的,强大的Mac OS 下安 ...

  9. 【技术累积】【点】【java】【30】代理模式

    基础 代理模式是Java常见的设计模式之一.所谓代理模式是指客户端并不直接调用实际的对象,而是通过调用代理,来间接的调用实际的对象. 什么是代理 参考现实生活中的代理 比如某个品牌的某个省的代理商,作 ...

  10. 03--QT教程(转自:豆子)

    http://blog.51cto.com/zt/20