Computer Transformation(规律,大数打表)
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以外,所有串的前面都是 ...
 
随机推荐
- 引用类型List<T>的比较
			
一:重新Equals和GetHashCode方法 /// <summary> /// 描 述:弹出模型对象列表比较器(根据ID比较) /// </summary&g ...
 - 在GridView控件里面绑定DropDownList控件
			
参考链接: http://www.aspsnippets.com/Articles/Populate-DropDownList-with-Selected-Value-in-EditItemTempl ...
 - Canvas使用渐变之-径向渐变详解
			
创建径向渐变使用 createRadialGrdient(x0,y0,r0,x1,y1,r1) 一共六个参数,分别代表: 起点的圆心坐标(第一个和第二个参数), 起点园的半径(第三个参数), 终点 ...
 - 【转】windows上自动设置java环境变量的脚本
			
转载:http://www.cnblogs.com/flowwind/p/4066146.html 近期打算学习安卓开发,于是乎要准备java开发环境,安装好jdk后,就要 设置java环境变量,ja ...
 - leetcode208 happynumber
			
19 is a happy number 12 + 92 = 82 82 + 22 = 68 62 + 82 = 100 12 + 02 + 02 = 1 class Solution {public ...
 - [Swust OJ 797]--Palindromic Squares(回文数水题)
			
题目链接:http://acm.swust.edu.cn/problem/797/ Time limit(ms): 1000 Memory limit(kb): 10000 Description ...
 - jquery选择器控制Html元素
			
1.JQuery中有addClass,removeClass,toggleClass addClass(class):为每个匹配的元素添加指定的类名 removeClass(class):从所有匹配的 ...
 - 写一个兼容性比较好的拖拽DEMO
			
写一个兼容性比较好的拖拽DEMO 查看Demo 思路 div盒子 鼠标按下事件onmousedown 鼠标移动事件onmousemove,获得鼠标的坐标,将div移动至鼠标的当前坐标 鼠标抬起事件om ...
 - vagrant 入门4
			
7. 打包 Packaging , 8080 end 2. 打包Project $ vagrant package --vagrantfile Vagrantfile.pkg 8. 打包完成后,在工程 ...
 - spoj 7001
			
/*** 大意:计算gcd(x,y,z) =1 0<= x, y , z <= n 问有多少个这样的对 莫比乌斯反演:(反演: 用结果推原因) 函数m(m)的定义如下: 莫比乌斯反演: * ...