AIM Tech Round 3 (Div. 1)-B. Recover the String
来源:互联网 发布:ios的编程框架 编辑:程序博客网 时间:2024/06/04 17:57
原题链接
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <map>#include <vector>#include <queue>#include <cmath>#define maxn 1000005#define MOD 1000000007#define INF 1e9using namespace std;typedef long long ll;char str[maxn];int main(){//freopen("in.txt", "r", stdin);ll a, b, c, d;scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);a *= 2;d *= 2;ll k1 = sqrt(a);ll k2 = sqrt(d);if(k1 * (k1 + 1) != a || k2 * (k2 + 1) != d){puts("Impossible");return 0;}if(a == 0 && b == 0 && c == 0 && d == 0){puts("0");return 0;}if(a == 0 && b == 0 && c == 0 && d){for(int i = 1; i <= k2 + 1; i++) str[i] = '1';puts(str+1);return 0;}if(a && b == 0 && c == 0 && d == 0){for(int i = 1; i <= k1 + 1; i++) str[i] = '0';puts(str+1);return 0;}if((k1+1) * (k2+1) != b + c){puts("Impossible");return 0;}k1++, k2++;ll cc = b / k2, e = b % k2;for(int i = 1; i <= k1 + k2; i++) str[i] = '0';for(int i = cc + 1; i <= cc + k2; i++) str[i] = '1';if(e){ str[cc+k2+1] = '1'; str[cc+k2+1-e] = '0'; } puts(str+1); return 0;}
0 0
- AIM Tech Round 3 (Div. 1)-B. Recover the String
- AIM Tech Round 3 (Div. 1) B. Recover the String(构造)
- AIM Tech Round 3 (Div. 1) B. Recover the String 构造
- AIM Tech Round 3 (Div. 2) -- D. Recover the String (思路题目--构造字符串)
- AIM Tech Round 3 (Div. 2) -- D. Recover the String (构造字符串)
- codeforces AIM Tech Round 3 (Div. 2)D. Recover the String
- AIM Tech Round 3 (Div. 2) D. Recover the String 构造、贪心、多坑、WA162
- CF AIM Tech Round 3 (Div. 2) D - Recover the String
- AIM Tech Round 3 (Div. 2) D. Recover the String (构造)
- AIM Tech Round (Div. 2)--B. Making a String
- Codeforces AIM Tech Round (Div. 2) B. Making a String
- AIM Tech Round Div 1
- AIM Tech Round 3 (Div. 2) B. Checkpoints
- codeforces AIM Tech Round 3 (Div. 2) B. Checkpoints
- Codeforces Aim Tech Round 3 (Div.2 )B.Checkpoints【思维】
- AIM Tech Round 3 (Div. 2) B. Checkpoints
- AIM Tech Round 3 (Div. 2) B. Checkpoints 排序、讨论
- AIM Tech Round 3 (Div. 2) -- B. Checkpoints (枚举)
- [hdu1133]Buy the Ticket(dp)
- Calendar类
- 高斯消元模板+十进制数
- 第一个缓冲区溢出的全过程实践
- delphi2007 打开项目时,突然报错,提示microsoft.net borland 报错
- AIM Tech Round 3 (Div. 1)-B. Recover the String
- codeforces 43C Lucky Tickets
- 关于eclipse启动报错An internal error occurred during: "reload maven project". java.lang.NullPointerExcepti
- Linux c==进程通信--有名管道(4)
- 数据结构实验之二叉树六:哈夫曼编码
- 【微信小程序】从入门到放弃
- JavaScript权威指南之闭包
- Problem 3 Largest prime factor (分解素因子)
- contentprovider的学习实例总结