Computer Transformation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6946 Accepted Submission(s): 2515
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?
3
1
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
const int MAXN=;
char dp[MAXN][MAXN];
char c[MAXN];
int x[MAXN],y[MAXN],z[MAXN];
void bigsum(char *a,char *b){
int len1,len2;
mem(x,);mem(y,);mem(z,);
len1=strlen(a);len2=strlen(b);
int len=max(len1,len2);
for(int i=len1-,j=;i>=;i--,j++)x[j]=a[i]-'';
for(int i=len2-,j=;i>=;i--,j++)y[j]=b[i]-'';
for(int i=;i<len;i++){
z[i]=x[i]+y[i]+z[i];
z[i+]+=z[i]/;
z[i]%=;
if(z[len])len++;
}
for(int i=len-,j=;i>=;i--,j++)c[j]=z[i]+'';
c[len]='\0';
}
int main(){
int n;
dp[][]='';dp[][]='\0';
dp[][]='';dp[][]='\0';
for(int i=;i<=;i++){
bigsum(dp[i-],dp[i-]);
bigsum(c,dp[i-]);
memcpy(dp[i],c,sizeof(c));
}
while(~scanf("%d",&n)){
printf("%s\n",dp[n]);
}
return ;
}
Computer Transformation(规律,大数打表)的更多相关文章
-
HDU 1041 Computer Transformation (简单大数)
Computer Transformation http://acm.hdu.edu.cn/showproblem.php?pid=1041 Problem Description A sequenc ...
-
hdu_1041(Computer Transformation) 大数加法模板+找规律
Computer Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
-
Computer Transformation(简单数学题+大数)
H - Computer Transformation Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d &am ...
-
(大数)Computer Transformation hdu1041
Computer Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
-
HDU 1041	 Computer Transformation(找规律加大数乘)
主要还是找规律,然后大数相乘 #include<stdio.h> #include<string.h> #include<math.h> #include<t ...
-
HDOJ-1041 Computer Transformation(找规律+大数运算)
http://acm.hdu.edu.cn/showproblem.php?pid=1041 有一个初始只有一个1的串 每次都按①0 -> 10;②1 -> 01;这两条规则进行替换 形如 ...
-
ACM学习历程—HDU1041 Computer Transformation(递推 &;&; 大数)
Description A sequence consisting of one digit, the number 1 is initially written into a computer. A ...
-
UVA - 1647 Computer Transformation(计算机变换)(找规律)
题意:初始串为一个1,每一步会将每个0改成10,每个1改成01,因此1会依次变成01,1001,01101001,……输入n(n<=1000),统计n步之后得到的串中,"00" ...
-
hdu 5351 规律+大数
题目大意:定义了一种fib字符串,问第n个fib串的前m个字母前后相等串的最大长度,大约就是这样的 其实主要读完题意的时候并没有思路,但是列几个fib字符串就会发现,除了fib1以外,所有串的前面都是 ...
随机推荐
-
java高新技术-类加载器
1.类加载器及委托机制的深入分析 > 类加载器的作用:一个java文件中的出现的类,首先要把这个类的字节码加载到内存中,这个类的信息放在硬盘的classPath下的class文件中, 把cla ...
-
.NET: C#: StopWatch
StopWatch class is used for calculate the timespan for that procedure. In Debug Mode it will be very ...
-
VS2012简单的使用感受+插件推荐
VS2012简单的使用感受+插件推荐http://www.cnblogs.com/tangge/archive/2013/03/12/2955367.html
-
Spring depends-on介绍
<!-- redis配置 --> <bean id="jedisPoolConfig" class="redis.clients.jedis.Jedis ...
-
Delphi的RTTI还分为对类和对象的判断,以及对普通属性的判断——相比之下,C++的RTTI实在太弱!
堂堂C++沦落到这个地步,也实在是够可怜的.
-
Java IO(一):IO和File
一.IO 大多数的应用程序都要与外部设备进行数据交换,最常见的外部设备包含磁盘和网络.IO就是指应用程序对这些设备的数据输入与输出,Java语言定义了许多类专门负责各种方式的输入.输出,这些类都被放在 ...
-
php之array_column 的使用
听说只有大牛级的高工才知道的函数array_column () 讲真,我才知道. (PHP 5 >= 5.5.0, PHP 7) array_column - 返回数组中指定的一列 说明 arr ...
-
[Swift]LeetCode468. 验证IP地址 | Validate IP Address
Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither ...
-
Fedora 19安装mysql
安装数据库模块 Mysql和Mysql-server#yum install mysql mysql-server 开启mysql服务#systemctl start mysqld.service同样 ...
-
javascript篇-typeof,instanceof,constructor,toString判断数据类型的用法和区别
javascript基本数据类型有:string,number,Boolean,undefined,null 引用类型(复杂类型):object, ES6中新增了一种数据类型:Symbol 以上数据类 ...