Coins and Queries

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.

Example

Input

5 4
2 4 8 2 4
8
5
14
10

Output

1
-1
3
2

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <numeric>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define eps 1e-8
#define PI acos(-1)
#define INF 0x3f3f3f3f
using namespace std;
const int N=200000 + 10 ;
typedef long long  LL;
const int dir[4][2]= { {1,0},{0,1},{-1,0},{0,-1} };

int GCD(int a,int b)
{
    return b ? GCD(b,a%b) : a;
}


int main()
{
    LL i,m,n,tra,fac=1;
    cin>>m>>n;
    map<LL,LL >mp;
    for(i=1; i<32; i++)
        fac*=2;
    for(i=0; i<m ; i++)
    {
        scanf("%lld",&tra);
        mp[tra]++;
    }
    for(i=0; i<n; i++)
    {
        LL ans=0,num,div=fac,dived,k;
        scanf("%lld",&dived);
        for(k=1; k<=32; k++)
        {
            num=min(dived/div,mp[div]);
            dived-=num*div;
            ans+=num;
            if(dived==0)
                break;
            div/=2;
        }
        if(dived!=0)
            printf("-1\n");
        else
            printf("%lld\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/codertcm/article/details/81239745