1、http://codeforces.com/contest/401/problem/C

2、题目大意:

给出n个0,m个1,将其组成一串,最终输出的串要求不能两个0挨着,不能三个1挨着,找情况模拟输出即可

3、题目:

C. Team
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.

Sample test(s)
Input
1 2
Output
101
Input
4 8
Output
110110110101
Input
4 10
Output
11011011011011
Input
1 5
Output
-1

3、AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{int n,m;while(scanf("%d%d",&n,&m)!=EOF){if(m<n-1 || m>(n+1)*2)printf("-1\n");else{int ans=m-(n-1);if(ans-2>=0){printf("11");ans-=2;}else if(ans>=1){printf("1");ans-=1;}for(int i=1; i<=n; i++){printf("0");if(ans>0 && i!=n){printf("11");ans--;}else if(ans==0 && i!=n){printf("1");}else if(i==n && ans>0){for(int j=1;j<=ans;j++)printf("1");}}printf("\n");}}return 0;
}
/*
2 1
*/

codeforces C. Team相关推荐

  1. Codeforces 757F: Team Rocket Rises Again(支配树)

    Description 2017新年到!Bash小朋友想给他的好友们送礼物.在他的国家里,有 n 座城市和 m 条双向道路(这里保证这 n 座城市是联通的).Bash住在城市 s 中.对于每个城市(包 ...

  2. CodeForces - 1316E Team Building(状压dp)

    题目链接:点击查看 题目大意:给出 n 个人,现在需要 p 个球员和 k 个啦啦队员,n 个人当啦啦队员以及当第 i 个位置的球员所做的贡献都会给出,现在问如何分配可以使得总贡献和最大 题目分析:因为 ...

  3. codeforces 932E Team Work 高等数学求导、dp

    题解 这是一道纯粹的数学求导题目. 首先我们先写出要求的公式. ans=∑r=1nCnrrkans = \sum_{r=1}^{n} C_n^{r}r^kans=∑r=1n​Cnr​rk 乍一看,雾草 ...

  4. 2021/10/14程式培力刷題記錄

    刷題記錄 A CodeForces 50A Domino piling #include<bits/stdc++.h> using namespace std; int main() {i ...

  5. 【Codeforces】401C Team (01010110...)

    http://codeforces.com/contest/401/problem/C 题目中,n表示0的个数,m表示1的个数,要求两个0不能连续,三个1不能连续 还要判断能否输出满足要求的序列,不满 ...

  6. codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/231/A 题意:问n道题目当中有多少道题目是至少两个人会的. C++代码: #include &l ...

  7. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)

    A题:一个三角形,一开始在C点,给边长a,b,c问上面走n-1次走多少步. ???为什么会写错??? #include<stdio.h> #include<string.h> ...

  8. 【Codeforces gym 102388】SUFE ICPC Team Formation Test,签到题BDG

    B Stars /* 题意:求二维平面上(x1,y1),(x2,y2)连成的直线上有多少个整数点 思路:以(x1,y1)为原点建立新的坐标系,答案为gcd(|x2-x1|,|y2-y1|)+1 */ ...

  9. Codeforces 107B Basketball Team 简单概率

    题目链接:点击打开链接 题意: 给定n m h 表示有m个部门,有个人现在在部门h 下面m个数字表示每个部门的人数.(包括他自己) 在这些人中随机挑选n个人,问挑出的人中存在和这个人同部门的概率是多少 ...

  10. Codeforces Round #441 (Div. 1, by Moscow Team Olympiad) C. National Property CF875C

    其实就是检查第i 跟 i+1 序列是否合法 合法就不理它 如果不合法再变一下 最后再拓补检查一下构造出的解是否合法 #include <iostream> #include <alg ...

最新文章

  1. 如何使用阿里云主机搭建lordofpomelo
  2. python代码翻译-python实现在线翻译
  3. [译]GC专家系列2:Java 垃圾回收的监控
  4. 生命游戏 并行化_新加坡电音制作人楚晴Jasmine《困兽游戏》,讲述爱情间的博弈...
  5. DevExpress XtraGrid RepositoryItemCheckEdit 复选框多选的解决方法(转)
  6. sort函数用于vector向量的排序
  7. BZOJ2555:SubString(SAM,LCT)
  8. TOGAF 知识点整理
  9. 计算机话筒技术指标,麦克风
  10. 基于opencv ,实现螺丝松动检测
  11. Cesium--模型(modle)的处理篇
  12. matplotlib中的imshow()绘图长宽比例失调,调整长宽比(备忘)
  13. 重要提醒:你有一份专属红包封面待查收!
  14. 全网最详细,宿主机ping虚拟机的主机名失败,但ping虚拟机的ip成功
  15. 脉冲宽度调制(SPWM)Simulink仿真教程
  16. 从一个运维人员的角度看微盟的这次删库跑路的节奏
  17. websocket 断网消息补发
  18. Python的安装和环境配置
  19. linux+bypy 定时上传到百度云盘
  20. matlab描述统计分析步骤,MATLAB实现描述性统计分析的例子例题

热门文章

  1. STM32学习----ADC(数模转换)
  2. Adaptive icon 一 :理解 Android 的「自适应图标」
  3. CodeForces - 864E FIRE(附带限制条件01背包)
  4. Python/Basemap绘制美国人口分布示意图
  5. Histromap of World History: The rise and fall of peoples and notions for 4000 years
  6. 英语词根词缀记忆大全
  7. 期货业-期货市场的产生
  8. c语言的论文,C语言论文
  9. 如何知道计算机是否支持64位,使用鲁大师怎么查看电脑CPU是否支持64位系统?...
  10. LazyT——C#基础知识回顾