CF1003BBinary String Constructing

Binary String Constructing

You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b 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 i

such that 1≤i<n and si≠si+1 (i=1,2,3,4). For the string "111001" there are two such indices i (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 s

is any binary string satisfying conditions described above. It is guaranteed that the answer always exists.

Examples

Input

Copy

2 2 1

Output

Copy

1100

Input

Copy

3 3 3

Output

Copy

101100

Input

Copy

5 3 6

Output

Copy

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个0,b个1,输出的序列中要满足x个T_{i}!=T_{i+1}

思路前x-1个按010101形式输出,第x个在序列后面接上剩余的0和1,比如01010110

补题的时候错了一发,时间超限,原因是数组开小了,所以看题和检查很重要的呀QAQ

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int a,b,x,aa,bb,t[205],i=0,j;
    scanf("%d %d %d",&a,&b,&x);
    aa=a;
    bb=b;
    if(a>=b)
    {
        t[0]=0;
        aa--;
    }
    else
    {
        t[0]=1;
        bb--;
    }
    if(x>1)
    {
        for(i=1; i<=a+b; i++)
        {
            if(t[i-1]==0)
            {
                t[i]=1;
                bb--;
            }
            else
            {
                t[i]=0;
                aa--;
            }
            x--;
            if(x==1)
                break;
        }
    }
    if(t[i]==1)
    {
        for(j=1; j<=bb; j++)
            t[++i]=1;
        for(j=1; j<=aa; j++)
            t[++i]=0;
    }
    else
    {
        for(j=1; j<=aa; j++)
            t[++i]=0;
        for(j=1; j<=bb; j++)
            t[++i]=1;
    }
    for(j=0; j<=i; j++)
        printf("%d",t[j]);
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值