-
Notifications
You must be signed in to change notification settings - Fork 9
/
EqualZeroesEqualOnes.cpp
71 lines (66 loc) · 1.34 KB
/
EqualZeroesEqualOnes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<bits/stdc++.h>
#include<iosteran.h>
using namespace std;
string solution(){
int x;
cin>>x;
string str="";
string a = "10", b = "01";
if(x==3){ return "010"; }
else if(x%4==0){
int temp = x/4;
while(temp--){
str = str + a;
}
temp = x/4;
while(temp--){
str = str + b;
}
}
else if(x%4==1){
int temp = x/4;
while(temp--){
str = str + a;
}
str.push_back('0');
temp = x/4;
while(temp--){
str = str + b;
}
}
else if(x%4==2){
int temp = x/4;
while(temp--){
str = str + a;
}
str.push_back('0');
str.push_back('0');
temp = x/4;
while(temp--){
str = str + b;
}
}
else if(x%4==3){
int temp = x/4;
while(temp--){
str = str + a;
}
str.push_back('0');
str.push_back('0');
str.push_back('0');
temp = x/4;
while(temp--){
str = str + b;
}
}
return str;
}
int main(){
int test;
cin>>test;
while(test--){
string ans = solution();
cout<<ans<<endl;
}
return 0;
}