# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67807 | osmanorhan | Binary Subsequences (info1cup17_binary) | C++17 | 661 ms | 652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset
using namespace std;
typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<int,ii> iii;
typedef pair<ii,ii> i4;
const int maxn = 200020;
const int maxm = 1000020;
const int MOd = 998244353;
int main() {
//freopen("asd.in","r",stdin);
//freopen("output17.txt","w",stdout);
int a;
scanf("%d",&a);
while( a-- ) {
int k;
scanf("%d",&k); k += 2;
int ans = 0;
int mini = 1e9, h = 0;
for(int i=1;i<k-i;i++) {
int x = i;
int y = k-i;
int step = 0;
while( x > 0 && y > 0 ) {
if( x > y ) step += x/y, x %= y;
else step += y/x, y %= x;
}
if( x > y ) swap( x, y );
if( y == 1 ) {
ans++;
if( step < mini ) {
mini = step;
h = i;
}
}
}
cout << ans+ans << endl;
int x = h;
int y = k-h;
vector<int> v;
while( x != y ) {
if( x > y ) x -= y, v.pb( 1 );
else y -= x, v.pb( 0 );
}
for(int i=v.size()-1;i>=0;i--) printf("%d ",v[i]); printf("\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |