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 ...
随机推荐
- Thymeleaf th:action
th:attr 任何属性值 <form action="subscribe.html" th:attr="action=@{/subscribe}"> ...
- msgrcv,msgsnd进程通信,消息的发送和接收
//进程通信,消息的发送和接收 //client.c #include <unistd.h> #include <sys/types.h> #include <sys/s ...
- Spark学习散点总结
使用Spark 时,通常会有两种模式.一.在交互式编程环境(REPL, a.k.a spark-shell)下实现一些代码,测试一些功能点.二.像MapReduce 那样提前编写好源代码并编译打包(仅 ...
- Thinkphp学习笔记-controller与view绑定
$this->display(); 通过上面的代码则可以输出controller所对应的view
- Linux网络编程之聊天程序(TCP协议之select)
服务器端:server.c #include <stdio.h> #include <stdlib.h> #include <errno.h> #include & ...
- PHP中调用外部命令的方法
在PHP中调用外部命令,可以用如下三种方法来实现: 方法一:用PHP提供的专门函数(四个): PHP提供4个专门的执行外部命令的函数:exec(), system(), passthru(), she ...
- Android之GPS定位详解
一.LocationManager LocationMangager,位置管理器.要想操作定位相关设备,必须先定义个LocationManager.我们可以通过如下代码创建LocationManger ...
- 算法笔记_146:TarJan算法的应用(Java)
目录 1 问题描述 2 解决方案 1 问题描述 Problem Description 为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M& ...
- 【转发】MVC Log4net
1.引用log4net库类 2.写配置,我一般是写在web.config <configSections> <section name="log4net" typ ...
- node:爬虫爬取网页图片
代码地址如下:http://www.demodashi.com/demo/13845.html 前言 周末自己在家闲着没事,刷着微信,玩着手机,发现自己的微信头像该换了,就去网上找了一下头像,看着图片 ...