gym I. Painting the natural numbers
来源:互联网 发布:c语言头文件是什么 编辑:程序博客网 时间:2024/05/17 08:36
这道数学题
刚开始以为按照样例的规律那样输出就可以了,但是wa了几发打表发现显然是错误的,样例只能到1023,而打表的规律可以做到大于1024.
然后曾想到0110222220110,这种方法,只是猜测,但是感觉好像并不正确就没有提交<从而得知,对于数论找规律题,即便不知道对不对,猜一个上去也是可以的>
然后搜了题解,发现这个方法是对的。。也不知道怎么证明的正确性。
因为0110后面加个2,可以连续加前面所有数+1个,然后后面只要前面出现过的数字即可。
每多一个数字,个数就是3*N+1
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>#include <queue>#include <math.h>#define V 1100#define E 1000100#define inf 99999999using namespace std;string s1,s2,s3,s4;int qq[1005000];int max1;int main(){ //freopen("in.txt","r",stdin); int i,j,k,f1,f2,f3,f4,t1,t2,t3,t4,n,m; int gg=0; qq[1]=0; qq[2]=1; qq[3]=1; qq[4]=0; t1=4; cin >>n; for(i=2;i<10;i++){ for(j=t1+1;j<=3*t1+1;j++){ if(j>n)break; if(j>=t1+1&&j<=2*t1+1) qq[j]=i; else qq[j]=qq[j-2*t1-1]; } t1=t1*3+1; } for(i=1;i<=n;i++) cout <<qq[i]; return 0;}
阅读全文
0 0
- gym I. Painting the natural numbers
- 20162017-ct-s03e02-codeforces-trainings-season-3-episode-2-en-I Painting the natural numbers
- Canvas Painting Gym
- Gym 100015 B Ball Painting
- Gym 100015B Ball Painting
- Am I painting?
- GYM 100285 I. The old Padawan(二分+简单模拟)
- GYM 101149 I.It's the Police(水~)
- GYM 100694 I.Goat in the Field(水~)
- Sheldon Numbers Gym
- Sheldon Numbers Gym
- joj 2677 The Natural Series
- Painting the Web
- sgu183 Painting the balls_dp
- [cf398B]Painting The Wall
- HNU13383:The Big Painting
- Painting The Wall CodeForces
- Codeforces Gym 100379I Move the queen to the corner! 威佐夫博弈变形 + 高精度
- 数据库索引简介以及如何选择索引列
- CentOS7.0安装配置redis集群
- 挑7
- IIC总线NOT burst模式
- 虚拟机Ubuntu14.04用respin制作LiveCD及ISO镜像
- gym I. Painting the natural numbers
- 线程简介
- JS之连接数组方法concat
- MySQL 5.6.14 win32 zip版安装
- Python基础(一)
- 41 WebGL绘制一个具有交互的立方体
- Android 微博打开指定用户界面
- Android Studio更新后打开老项目报错,但是能运行
- java日期操作