UVA 1647 Computer Transformation
https://vjudge.net/problem/UVA-1647
题意:
开始有一个1,接下来每一步1变成01,0变成10
问n不之后00的个数
打表找规律
第3步之后:
如果第i步之后有x个字符,
那么第i+1步之后 的后x个字符与第i步一样
前x个字符是第i步取反
所以00得个数由三部分组成
1、上一步00的个数
2、上一步11的个数
3、当i为偶数时,前x个字符的最后一个是0,后x个字符的第一个是0,00个数+1
f[i][0]=f[i-1][0]+f[i-1][1]+!(i&1)
f[i][1]=f[i-1][0]+f[i-1][1]
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct BigInteger
{
int len;
int num[];
BigInteger() { len=; memset(num,,sizeof(num));}
BigInteger operator + (BigInteger p) const
{
BigInteger b;
b.len=max(len,p.len);
int x=max(len,p.len);
for(int i=;i<=x;i++)
{
b.num[i]+=num[i]+p.num[i];
b.num[i+]=b.num[i]/;
b.num[i]%=;
}
if(b.num[x+]) x++;
b.len=x;
return b;
}
void operator = (BigInteger p)
{
this->len=p.len;
for(int i=;i<=len;i++) this->num[i]=p.num[i];
}
void print()
{
for(int i=len;i;i--) printf("%d",num[i]);
printf("\n");
}
};
BigInteger f[][];
BigInteger e;
int main()
{
f[][].len=;
f[][].num[]=;
f[][].len=;
f[][].num[]=;
e.len=;
e.num[]=;
for(int i=;i<=;i++)
{
f[i][]=f[i-][]+f[i-][];
if(i&) f[i][]=f[i-][]+f[i-][];
else f[i][]=f[i-][]+f[i-][]+e;
}
int n;
while(scanf("%d",&n)!=EOF) f[n][].print();
}
UVA 1647 Computer Transformation的更多相关文章
- UVA - 1647 Computer Transformation(计算机变换)(找规律)
题意:初始串为一个1,每一步会将每个0改成10,每个1改成01,因此1会依次变成01,1001,01101001,……输入n(n<=1000),统计n步之后得到的串中,"00" ...
- HDU 1041 Computer Transformation (简单大数)
Computer Transformation http://acm.hdu.edu.cn/showproblem.php?pid=1041 Problem Description A sequenc ...
- Computer Transformation(规律,大数打表)
Computer Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- hdu_1041(Computer Transformation) 大数加法模板+找规律
Computer Transformation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- (大数)Computer Transformation hdu1041
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 ...
- UVa 1647 (递推) Computer Transformation
题意: 有一个01串,每一步都会将所有的0变为10,将所有的1变为01,串最开始为1. 求第n步之后,00的个数 分析: 刚开始想的时候还是比较乱的,我还纠结了一下000中算是有1个00还是2个00 ...
- Computer Transformation(hdoj 1041)
Problem Description A sequence consisting of one digit, the number 1 is initially written into a com ...
- ACM学习历程—HDU1041 Computer Transformation(递推 && 大数)
Description A sequence consisting of one digit, the number 1 is initially written into a computer. A ...
随机推荐
- CS小分队第二阶段冲刺站立会议(5月30日)
昨日成果:解决了前天遗留的问题,实现了主界面对于电脑上应用的添加和删除 遇到问题:添加和删除按钮时候,按钮位置图像与北京图片冲突,会出现闪动现象. 删除是通过右键单击出现菜单,其中有删除的选项,但是这 ...
- pandas中DataFrame的ix,loc,iloc索引方式的异同
pandas中DataFrame的ix,loc,iloc索引方式的异同 1.loc: 按照标签索引,范围包括start和end 2.iloc: 在位置上进行索引,不包括end 3.ix: 先在inde ...
- 团队项目选题报告(I know)
一.团队成员及分工 团队名称:I know 团队成员: 陈家权:选题报告word撰写 赖晓连:ppt制作,原型设计 雷晶:ppt制作,原型设计 林巧娜:原型设计,博客随笔撰写 庄加鑫:选题报告word ...
- HDU 5211 Mutiple 水题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5211 题解: 1.筛法: #include<iostream> #include< ...
- web压力测试_(收集)
作者:ZeldaZzz链接:http://www.zhihu.com/question/19867883/answer/89775858来源:知乎著作权归作者所有,转载请联系作者获得授权. 一个完整的 ...
- 移动平台的meta标签
这个meta在移动平台上有非常神奇的地方. 1. <meta name="viewport" content="width=device-width; initia ...
- PAT 甲级 1050 String Subtraction
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...
- bootstrap心得
最近在弄个人的博客,之前对bootstrap的使用老是感觉使用的一般 幸好在看了慕课网的一个老师的实例教程之后,才感觉是真正对前端使用bootstrap有了一点理解 首先就是. 这些标签,其实都是相当 ...
- bootstrap练习制作网页
导航条 <nav class="navbar navbar-default"> <div class="container-fluid"> ...
- luogu 1344 追查坏牛奶(最小割)
第一问求最小割. 第二问求割边最小的最小割. 我们直接求出第二问就可以求出第一问了. 对于求割边最小,如果我们可以把每条边都附加一个1的权值,那么求最小割是不是会优先选择1最少的边呢. 但是如果直接把 ...