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. Java数组去重(利用数组,不借助集合)

    今天有个同学问我说老师,Java里边数组怎么去重,在不借助List集合的情况下,最后呢我整理了一下,打算发一篇博文,希望能帮助到有用的人,大佬绕过 public static void arrUniq ...

  2. Vue组件库elementUI 在el-row 或 el-col 上使用@click无效失效,

    问题: elementUI 在el-row 或者 el-col 上使用@click失效, 解决: 在click后面加上 .native .要使用@click.native=”handler()”才行, ...

  3. 基于ASP.Net Core开发一套通用后台框架记录-(项目的搭建)

    写在前面 本系列博客是本人在学习的过程中搭建学习的记录,如果对你有所帮助那再好不过.如果您有发现错误,请告知我,我会第一时间修改. 前期我不会公开源码,我想是一点点敲代码,不然复制.粘贴那就没意思了. ...

  4. Boost.Build特点(译)

    Boost.Build Boost.Build makes it easy to build C++ projects, everywhere. Boost.Build让构建C++项目在任何地方都很容 ...

  5. 【洛谷3224/BZOJ2733】[HNOI2012]永无乡 (Splay启发式合并)

    题目: 洛谷3224 分析: 这题一看\(n\leq100000\)的范围就知道可以暴力地用\(O(nlogn)\)数据结构乱搞啊-- 每个联通块建一棵Splay树,查询就是Splay查询第k大的模板 ...

  6. ZOJ 3666 博弈 SG函数

    SG函数: 对于任意状态,定义SG(x)=mex(S),其中S是x的后继状态的SG函数值集合,mex(S)表示不再S内的最小非负整数 SG(X)=0当且仅当x为必败态. 解: 构造一个有向无环图(树) ...

  7. UE4源码版食用要记

    UE4源码版和预编译版不能共享工程,这和插件版是一样的. 一般来说我都是在VS中生成编辑器,于编辑器中添加新类,VS中编辑代码. 编译引擎的时候编译配置使用的是devepolmenteditor.开发 ...

  8. x264

    x264 x264  h264  1. x264调用主要过程 x264_param_default():设置参数集结构体x264_param_t的缺省值. x264_picture_alloc():为 ...

  9. 显示log里的ansi codecs颜色字符

    方法: vim AnsiEsc插件 http://www.vim.org/scripts/script.php?script_id=302 less -r cat和tail命令都可以正常显示,而且ta ...

  10. includes() 方法用来判断一个数组是否包含一个指定的值,根据情况,如果包含则返回 true,否则返回false。

    注意:对象数组不能使用includes方法来检测. JavaScript Demo: Array.includes() var array1 = [1, 2, 3]; console.log(arra ...