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以外,所有串的前面都是 ...
随机推荐
- HDOJ 2102 A计划(bfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2102 思路分析: <1>搜索方法分析:由于需要寻找最短的找到公主的路径,所以采用bfs搜索 ...
- 第一讲 一个简单的Qt程序分析
本文概要:通过一个简单的Qt程序来介绍Qt程序编写的基本框架与一些Qt程序中常见的概念 #include <QApplication> #include <QPushButton&g ...
- Uber 叫车时,弹出以下代码导致无法打车(An email confirmation has been sent to...),解决办法
”鄙人用了虚拟信用卡+广西的手机号码+163邮箱申请了Uber的新帐号...然后输入mastercn优惠码,上网查询只有这个优惠码,应该就能免费的使用一次用车,限额200元.但在点用车时 弹出窗口提 ...
- RADOS工作原理
转:http://www.csdn.net/article/2014-04-08/2819192-ceph-swift-on-openstack-m/2 Ceph的工作原理及流程 本节将对Ceph的工 ...
- openstack之Nova
一.Nova简介及其核心组件: Nove在openstack中提供计算服务: Nova核心模块: Controller Nova-api:提供API,包括命令行API; Nova-schedule: ...
- JavaSript模块化 && AMD CMD 详解.....
模块化是指在解决某一个复杂问题或者一系列的杂糅问题时,依照一种分类的思维把问题进行系统性的分解以之处理.模块化是一种处理复杂系统分解为代码结构更合理,可维护性更高的可管理的模块的方式.可以想象一个巨大 ...
- iOS 项目中的NSNotification简单使用
iOS中NSNotification的简单使用 好久没有写过博客了,总是遇到问题查一下,今天查的又是一个老问题,想了想,还是记录一下!今天在项目开发中遇到一个配置及时性处理的问题,想了想之后决定用通知 ...
- [C#参考]字符编码
微软的那个臭屁的JOEL(就是写<JOEL说软件>的那个牛人)曾说:“每一位软件开发人员必须.绝对要至少具备UNICODE与字符集知识(没有任何例外)”,我也常常困扰于字符集的转换等很多问 ...
- Node.js学习笔记2(安装和配置Node.js)
1.安装 windows下安装,在http://nodejs.org下载安装包进行安装即可. linux下安装,使用yum或者下载源码进行编译. ...
- Myeclipse代码提示及如何设置自动提示
Myeclipse代码提示及如何设置自动提示 (2011-11-18 00:38:41) 转载▼ 标签: 杂谈 分类: Java 1. 设置代码自动提示window --> preference ...