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. js获取request参数值(javascript 获取request参数值的方法)

    jsp 中的js,可以用el表达式来提取:var value = "${requestScope.XXX}"; 注:XXX为你的参数名 如:http://localhost:808 ...

  2. Android之NDK开发(转载)

    http://www.cnblogs.com/devinzhang/archive/2012/02/29/2373729.html 一.NDK产生的背景 Android平台从诞生起,就已经支持C.C+ ...

  3. PCB javascript解析Gerber274X格式实现方法

    解析钻Gerber274X格式前首先得了解此格式,这样才能更好的解析呀. 一个Gerber274X里面包含的基本信息如下: 1.单位:公式mm,英制inch 2.省零方式:前省零,后省零 3.坐标方式 ...

  4. 【java基础】java中重载与重写的区别

    重载(Overloading) (1) 方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载Overloading是一个类中多态性的一种表现. ( ...

  5. js indexOf 列表筛选

    先来一堆效果图:  代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  6. cookie范例

    GET /locate/api/getLocByIp?key=C6E22B7D480E3312C74EC7EF013E50C5&callback=bowlder.cb._0 HTTP/1.1 ...

  7. CDR真实图片转水墨画效果制作教程

    CorelDRAW创造性滤镜组是最具有创造力的滤镜,使用里面的散开滤镜能够实现类似于水墨的表现手法,然后再结合图层的合并模式,让您的图片产生意想不到的视觉效果.本文将利用CorelDRAW软件中提供的 ...

  8. PHP 数据库连接 (Mysql Mysqli PDO)

    1.PHP与Mysql扩展(本扩展自 PHP 5.5.0 起已废弃,并在将来会被移除),PHP原生的方式去连接数据库,是面向过程的 <?php $mysql_conf = array( 'hos ...

  9. logback日志配置文件

    application.properties application.properties logback-spring.xml <?xml version="1.0" en ...

  10. 零基础到精通Linux,从这篇文章开始

    2018年想做Linux运维的人应该如何学习才能快速精通Linux? Linux入门这么简单,为什么很多人学不会? 想要成为一个合格的运维工程师,到底怎么才能从零开始精通Linux? 作为一个运维小白 ...