题解 | 01串题

01串题

https://www.nowcoder.com/practice/05b85386f9ac4361b067d13d6095e457

#include <iostream>
using namespace std;

int main() {
    int a,b,x;
    cin>>a>>b>>x;
    x/=2;
    a-=x;
    b-=x;
    if(a<0||b<0||a&1||b&1){
        cout<<"-1\n";
    }else {
        while(x--){
            cout<<"01";
        }
        while(a--)cout<<"0";
        while(b--)cout<<"1";
        cout<<"\n";
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务