日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Binary String Constructing(CF-1003B)

發布時間:2025/3/17 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Binary String Constructing(CF-1003B) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。