#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 600005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(s) (int)s.size()
ll T, n, a[N], t, ans,b[25];
string s, g;
map <string,int> vis;
int main () {
cin >> n;
while(n--) {
cin >> t;
s = g = "";
int ans = t + 1;
for(int i=1;i<=t;i++) {
g+='1';
}
for(int i = 0; i <= t;i++) {
int x1 = t - i, x2 = i;
s = "";
while(x1 != x2) {
if(x1 > x2) {
x1 -= (x2 + 1);
s += '1';
}
else {
x2 -= (x1 + 1);
s += '0';
}
}
if(x1 == 0 && x2 == 0 && sz(s) < sz(g)) g = s;
if (x1 > 0 || x2 > 0)ans--;
}
cout << ans << '\n';
for(int i = 0 ;i<sz(g); i++) {
cout << g[i] << " ";
}
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |