【codeforce 708e】Recover the String
来源:互联网 发布:树莓派3 有线网络配置 编辑:程序博客网 时间:2024/06/10 01:24
每一次写codeforce的时候都感觉好像智商不够用,各种套路脑洞。结果下来看题解又莫名.....
首先 我们需要知道0和1各出现了多少次,就好够造了,因为每增加一个0或者1 00,11的对数就会增加之前出现的0,才数个,求出了0,1的总个数以后我们先特判不可能的情况,很显然00,11的个数和==1的个数*0的个数。好了,现在来构造,考虑这样一个事实如果01的个数比1多说明了什么?说明之前一定有出现多个0来组合出01,所以每次添加一个0对于01的贡献就是还没有出现的1的个数,10同理。然后每次0--,1--
#include<cstdio>#include<cstring>#include<iostream>using namespace std;int oo,ol,lo,ll,len,nl,no,c1,c0;string ans;int main(){scanf("%d%d%d%d",&oo,&ol,&lo,&ll);if(oo+lo+ol+ll==0)return printf("0"),0;int num0=0,num1=0;while(num0+c0<=oo)num0+=c0,c0++;while(num1+c1<=ll)num1+=c1,c1++;if(!lo&&!ol&&!oo)c0=0;if(!ll&&!lo&&!ol)c1=0;len=c1+c0;if(c1*c0!=lo+ol||num0!=oo||num1!=ll)return printf("Impossible"),0;for(int i=1;i<=len;i++){if(ol>=c1){printf("0");ol-=c1;c0--;}else{printf("1");lo-=c0;c1--;}}return 0;}
0 0
- 【codeforce 708e】Recover the String
- codeforces 708B-Recover the String
- CodeForces 708B Recover the String
- codeforces Recover the String
- [codeforces]Recover the String
- Codeforces Problem 708B Recover the String(implementation&math)
- 【CF 708B】Recover the String(组合+瞎搞)
- CodeForce 710E - Generate a String(dp)
- 【CodeForce 710E】Generate a String
- codeforces 709 D Recover the String (构造)
- Codeforce 632C The Smallest String Concatenation
- codeforce 44E Anfisa the Monkey (记忆搜索)
- 【LCA】CodeForce #326 Div.2 E:Duff in the Army
- 构造(Recover the String,cf 709D)
- cf 709D Recover the String(构造题)
- 【codeforces709D】Recover the String——大水题
- AIM Tech Round 3 (Div. 1)-B. Recover the String
- codeforces 709D Recover the String (构造+模拟)
- HDOJ.2501 Tiling_easy version
- 奇异值分解(SVD)详解及其应用
- Java编程思想(第六章)
- 怎样切换Java的jre类库
- 信号阻塞问题
- 【codeforce 708e】Recover the String
- springxml的注入方式
- 02-线性结构4 Pop Sequence (25分)
- 【索引】Codeforces
- 错误51error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突 opencv_core248d.lib opencv_core248d.dll
- linux
- 数据挖掘十大经典算法(4)Apriori
- 去掉Myeclipse对JS等文件的验证(Cannot return from outside a function or method)
- YII2 安装