Codeforces Round #235 (Div. 2) C. Team
1 second
256 megabytes
standard input
standard output
Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that:
- there wouldn't be a pair of any side-adjacent cards with zeroes in a row;
- there wouldn't be a group of three consecutive cards containing numbers one.
Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way.
The first line contains two integers: n (1 ≤ n ≤ 106) — the number of cards containing number 0; m (1 ≤ m ≤ 106) — the number of cards containing number 1.
In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.
1 2
101
4 8
110110110101
4 10
11011011011011
1 5
-1
讲解:n个0,和m个1,组成的1和0的组合,且不能连续出现两个0挨着,也不能同时出现3个1挨着:
AC代码:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int a,b;
while (~scanf("%d %d",&a,&b))
{
if (b>*a+||a>b+)
puts("-1");
else
{
if (a==b+)
{
printf("");
a--;
}
while (a+b>)
{
if (b>a && a>)
{
printf("");
b-=,a--;
} else if (b==a)
{
printf("");
a--;b--;
} if (a== && b!=)
{
printf("");
b--;
}
}
}
puts("");
}
return ;
}
Codeforces Round #235 (Div. 2) C. Team的更多相关文章
- Codeforces Round #235 (Div. 2)C、Team
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; cin & ...
- Codeforces Round #235 (Div. 2)
A. Vanya and Cards time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(如压力dp)
Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard i ...
- codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)
题目链接:http://www.codeforces.com/problemset/problem/231/A题意:问n道题目当中有多少道题目是至少两个人会的.C++代码: #include < ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers 状压dp+数位dp
题目链接: http://codeforces.com/problemset/problem/401/D D. Roman and Numbers time limit per test4 secon ...
- Codeforces Round #235 (Div. 2) B. Sereja and Contests
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- Codeforces Round #235 (Div. 2) A. Vanya and Cards
#include <iostream> using namespace std; int main(){ int n,x; cin >> n >> x; ; ; i ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)
D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...
- Codeforces Round #279 (Div. 2) A. Team Olympiad 水题
#include<stdio.h> #include<iostream> #include<memory.h> #include<math.h> usi ...
随机推荐
- Latex 语法总结——层次结构
层次结构~~documentclass[a4paper,11pt]{article}\usepackage{CJKutf8}\usepackage[top=1in, bottom=1in, left= ...
- ECMA-262,第 5 版 最新 JavaScript 规范
ECMA-262,第 5 版 最新 JavaScript 规范 Rob Larsen, 界面架构师, IBM 简介: 了解 ECMAScript 规范的历史,查看它的众多重要新特性和新概念. 发布日期 ...
- 策略模式Strategy——回家乘什么车?
1.问题与模式 时间:2014年6月 学校:廊坊师范 家:石家庄 人物:学生 又快到期末考试了,回家的节奏也奔上日程.无聊之余就想想这次回家的事儿.对我来说回家主 ...
- Backup and restore of FAST Search for SharePoint 2010
一个同事问我一个问题: 如果FAST Search for SharePoint 2010被full restore到了一个之前的时间点, 那么当FAST Search重新开始一个增量爬网的时候, 会 ...
- JavaScript hash
location.hash -- 返回URL#后面的内容,如果没有#,返回空 hash,中文"哈希" 引用网址:http://www.dreamdu.com/javascript/ ...
- 用asp.net还原与恢复sqlserver数据库
上次做了个项目,涉及到数据库的还原和恢复,到网上找了一下,是利用SQLDMO实现的,只要添加SQLDMO引用就好了,然后利用下边的类的方法就可以实现了. 我把原作者的类扩充了一下,可以自动识别web. ...
- Hadoop I/O
Hadoop自带一套原子操作用于数据I/O.当中一些技术,如数据完整性保持和压缩,对于处理多达数个TB的数据时.特别值得关注.另外一些Hadoop工具或API.所形成的构建模块可用于开发分布式系统.比 ...
- 我的Mac必备软件
1.Svn工具: Cornerstone_v2.7.10 2.iPhone配置文件管理 iPhoneConfigUtility.dmg 3.有道 for mac http://cidian.youda ...
- win10 当前操作环境不支持支付宝控件 完美解决办法
第一步,修改系统配置 在运行中输入“gpedit.msc”打开本地组策略编辑器: 打运行窗口的方法是:按win键+R (按下win键再按R键之后 同时松开) win键 即windows 的微标键 如 ...
- Thinkpad X201 Gobi2000 上电信3G网络
网上的教程大多有点小问题,许多都不完整,今天放出系统化.理论化的设置方法,附送上所有软件. 一.本教程适用范围:1.gobi 2000 正式版 FRU:60Y3263 (带MEID.IMEI)2.- ...