Binary String Constructing CodeForces - 1003B (构造)

You are given three integers aa, bb and xx. Your task is to construct a binary string ss of length n=a+bn=a+bsuch that there are exactly aa zeroes, exactly bb ones and exactly xx indices ii (where 1≤i<n1≤i<n) such that si≠si+1si≠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<n1≤i<n and si≠si+1si≠si+1 (i=1,2,3,4i=1,2,3,4). For the string "111001" there are two such indices ii (i=3,5i=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 aa, bb and xx (1≤a,b≤100,1≤x<a+b)1≤a,b≤100,1≤x<a+b).

Output

Print only one string ss, 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 个0, b 个1 组成一个 n=a+b 的字符串,需要有 x 个下标满足 Sx!=Sx+1 的条件

例如 1010000   x 是由下标  0,1,2(数组从0 开始的)组成的,满足上述的条件

思路:

需要构造和思维,按照题意构造出来符合题意的即可
做法:

先从开始按 1,0 交错的顺序构造出 x -1 个不同的,然后在结尾把剩余的给输出同时需要再构造出来一个前后不同的

例如 构造好前 x-1 个是  101010 ,还剩下 3个1,5个0,还需要再构造出来一个不同的,就是 10101000000111

如果 1的个数 大于 0 的个数,则先输出 1,否则相反

Code:

#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
    int a,b,x,n;
    char ans[205];
    scanf("%d %d %d",&a,&b,&x);
    if(a>b){
        a--;
        ans[0]='0';
    }
    else{
        b--;
        ans[0]='1';
    }
    int flag=1;
    while(x>1)
    {
        x--;
        if(ans[flag-1]=='1')
        {
            ans[flag++]='0';
            a--;
        }
        else{
            ans[flag++]='1';
            b--;
        }
    }
    if(ans[flag-1]=='1')
    {
        while(b--)
            ans[flag++]='1';
        while(a--)
            ans[flag++]='0';
    }
    else
    {
        while(a--)
            ans[flag++]='0';
        while(b--)
            ans[flag++]='1';
    }
    ans[flag]='\0';
    printf("%s\n",ans);

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值