Problem Description

You are given three integers aa, bb and xx. Your task is to construct a binary string ss of length n=a+b such that there are exactly aa zeroes, exactly bb ones and exactly x indices i (where 1≤i<n) such that si≠si+1. It is guaranteed that the answer always exists.

For example, for the string "01010" there are four indices ii such that 1≤i<n and si≠si+1 (i=1,2,3,4). For the string "111001" there are two such indices ii (i=3,5).

Recall that binary string is a non-empty sequence of characters where each character is either 0 or 1.

Input

The first line of the input contains three integers a, b and x (1≤a,b≤100,1≤x<a+b).

Output

Print only one string s, where ss is any binary string satisfying conditions described above. It is guaranteed that the answer always exists.

Examples

Input

2 2 1

Output

1100

Input

3 3 3

Output

101100

Input

5 3 6

Output

01010100

Note

All possible answers for the first example:

1100;
0011.

All possible answers for the second example:

110100;
101100;
110010;
100110;
011001;
001101;
010011;
001011.

题意:给出 a,b,x,要求输出一个含有 a 个 0,b 个 1 的字符串,要求这个字符串串刚好有 x 个 ai,满足 ai != ai+1

思路:模拟,判断奇偶关系,按要求输出即可,需要注意的是 1 和 0 谁放在前的情况。

Source Program

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<vector>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define N 10001
#define MOD 123
#define E 1e-6
using namespace std;
int main()
{int a,b,x;while(scanf("%d%d%d",&a,&b,&x)!=EOF){if(x%2){int num=x/2;//记录如果连续输出01/10有多少位相邻数字不一样的if(a>b){while(num--)printf("01");a-=(x/2),b-=(x/2);//记录剩余的1、0个数while(a--)printf("0");while(b--)printf("1");printf("\n");}else{while(num--)printf("10");a-=(x/2),b-=(x/2);//记录剩余的1、0个数while(b--)printf("1");while(a--)printf("0");printf("\n");}}else{int num=x/2;if(a>b){for(int i=1;i<=num-1;i++)printf("01");a=a-(x/2)+1,b=b-(x/2)+1;//记录剩余的1、0个数printf("0");a--;while(b--)printf("1");while(a--)printf("0");printf("\n");}else{for(int i=1;i<=num-1;i++)printf("10");a=a-(x/2)+1,b=b-(x/2)+1;//记录剩余的1、0个数printf("1");b--;while(a--)printf("0");while(b--)printf("1");printf("\n");}}}return 0;
}

Binary String Constructing(CF-1003B)相关推荐

  1. 二进制数与十进制数相互转换 string陷阱(赋值错误) 汉字分为两个字符 string123 string字符串逆转

    二进制数与十进制数相互转换: 二进制数(数组)转换成十进制数的函数: BtoO(char str[]) { int lg,sum=0,j=1; lg=strlen(str)-1; for(;lg> ...

  2. ES6, Angular,React和ABAP中的String Template(字符串模板)

    String Template(字符串模板)在很多编程语言和框架中都支持,是一个很有用的特性.本文将Jerry工作中使用到的String Template的特性做一个总结. ES6 阮一峰老师有一个专 ...

  3. 04-树6 Complete Binary Search Tree(30 分)

    title: 04-树6 Complete Binary Search Tree(30 分) date: 2017-11-12 14:20:46 tags: - 完全二叉树 - 二叉搜索树 categ ...

  4. 814. Binary Tree Pruning(C语言)

    814. Binary Tree Pruning(C语言) 深度优先搜索树 + 剪枝 题目 Given the root of a binary tree, return the same tree ...

  5. 【解题报告】随便练练二(CF 2300)

    [解题报告]随便练练二(CF 2300) A:Antimatter | CF383D 题意 思路 :DP 代码 B:Physical Education Lessons | CF915E 题意 思路一 ...

  6. Codeforces Round #617 (Div. 3) String Coloring(E1.E2)

    (easy version): 题目链接:http://codeforces.com/contest/1296/problem/E1 题目一句话就是说,两种颜色不同的字符可以相互换位, 问,对这字符串 ...

  7. 二叉搜索树(Binary Search Tree)(Java实现)

    文章目录 1.二叉搜索树 1.1. 基本概念 1.2.树的节点(BinaryNode) 1.3.构造器和成员变量 1.3.公共方法(public method) 1.4.比较函数 1.5.contai ...

  8. 1043 Is It a Binary Search Tree(二叉查找树BST)

    1043 Is It a Binary Search Tree 0.题目 A Binary Search Tree (BST) is recursively defined as a binary t ...

  9. 深入理解C++中string类(详解)

    深入理解C++中string类 背景介绍:在C++中使用string.h和cstring并不是所要介绍的string类指的是C语言库中字符串,而本文所要介绍的是string类.要使用string类主要 ...

最新文章

  1. Linux驱动技术(一) _内存申请
  2. c51语言的标准库函的头文件,C51编程中头文件的使用
  3. windows下安装composer方法(不修改PATH环境变量)
  4. 听说你们找我很久了?
  5. 搭建K8s集群(二进制方式)-搭建步骤介绍
  6. docker下安装nacos 并使用mysql数据库
  7. 外设驱动库开发笔记13:MLX90614红外温度传感器驱动
  8. 黑盒法测试c语言,黑盒测试的测试用例设计方法(经典理论知识,推荐)
  9. 想要酷炫大气的网页设计?这样做超吸睛
  10. 金三银四面试季—20道精选JVM重点面试问题!
  11. Android JNI的调用过程
  12. Windows消息大全(转载)
  13. 每周学一点Egret(17)default.thm.json 文件编译小坑
  14. NYOJ:71-独木舟上的旅行
  15. 因为是你 所以没关系:伤感日志
  16. 插入排序、希尔排序(Shell)、选择排序、堆排序、冒泡排序、快速排序、归并排序和基数排序(桶排)的 时间复杂度和空间复杂度
  17. vue进阶测试——生命周期和异步加载的微妙关系
  18. web前端开发面试题,都是整理出的精华
  19. 12期 11月期刊自荐
  20. 在职学计算机,在职人员怎么参加院校开设的计算机在职研究生学习?

热门文章

  1. 包教包会,7段代码带你玩转Python条件语句
  2. 大数据没用?!张小龙:我们很少看统计数据!
  3. CAN和CANOpen的关系
  4. 面试基操:微服务拆分需要考虑什么因素?
  5. 骆俊武:五年了,我的技术管理成长之路
  6. 程超:突破瓶颈!如何不断的提高自己
  7. 实惨!连各大编程语言都摆起地摊了!
  8. 钉钉崩,钉钉崩,钉钉崩完QQ群崩...
  9. maven如何合并两个war到一个war项目中
  10. JEECG开源团队招募新成员 2014年