[NOIP2017模拟]构造
来源:互联网 发布:手机淘宝比价软件 编辑:程序博客网 时间:2024/06/06 01:46
2017.8.29 T2 1953
样例数据
输入
10
输出
0102010301
备注
【数据范围】
十个点 N 分别为:20 500 1023 1024 1400 1899 2200 5000 15000 25000 。
注意:代码长度不能超出 100 kb
分析:样例的构造法是二进制
显然这样的过不了的(只能到1023)
我们这样来构造这个序列
0110
0110 22222 0110
0110 22222 0110 33333333333333 0110 22222 0110
这样一直下去 (不断加同一个数直到这个数第一位的两倍,再把整个这个数之前的部分复制到后面来,继续加入新数)
观察可以发现这样构造没有造成浪费
可以通过 25000
代码
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<ctime>#include<cmath>#include<algorithm>#include<cctype>#include<iomanip>#include<queue>#include<set>using namespace std;int getint(){ int sum=0,f=1; char ch; for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar()); if(ch=='-') { f=-1; ch=getchar(); } for(;ch>='0'&&ch<='9';ch=getchar()) sum=(sum<<3)+(sum<<1)+ch-48; return sum*f;}string s;int n,star,num;int main(){ //freopen("number.in","r",stdin); //freopen("number.out","w",stdout); n=getint(); s="0110"; star=4; num=1; while(star<n) { num++; string s2; for(int i=star+1;i<=2*star+1;++i) s2+=num+'0'; star=3*star+1; s=s+s2+s; } for(int i=0;i<n;++i) cout<<s[i]; return 0;}
本题结。
阅读全文
0 0
- [NOIP2017模拟]构造
- 【NOIP2017模拟赛】构造 A+B Problem(好题)
- NOIP2017模拟赛1
- NOIP2017模拟赛8
- NOIP2017模拟赛9
- [NOIP2017模拟]切蛋糕
- [NOIP2017模拟]随机图
- [NOIP2017模拟]能源
- [NOIP2017模拟]电影
- [NOIP2017模拟]鸭舌
- [NOIP2017模拟]permut
- [NOIP2017模拟]beautiful
- [NOIP2017模拟]路径
- [NOIP2017模拟]流
- [NOIP2017模拟]subset
- [NOIP2017模拟]hello
- [NOIP2017模拟]table
- [NOIP2017模拟]board
- 华为机试-字符串的分割
- activeMQ发布订阅者模式使用
- 传感器
- Spring Cloud开发注意事项
- 神经网络与深度学习(8)
- [NOIP2017模拟]构造
- 5. Longest Palindromic Substring(求最长回文子字符串)
- 封装Hibernate的Session操作和增删查改的工具类
- tomcat启动和停止时java.net.ConnectException:Connection refused:connect
- 如何在64位的Win10系统下安装.NET Framework 3.0
- 滴滴一面面经
- jQuery的属性与样式
- python-深拷贝和浅拷贝
- android AP侧通过sensor_class挂载sensor的一种方案