이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
pii gcd(int x,int y) {
if(x<y) swap(x,y);
if(y==0) return mp(x,0);
pii ret=gcd(y,x%y);
ret.nd+=(x/y);
return ret;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--) {
int k,cnt=0,a1=-1,a2;
cin>>k;
for(int i=1;i<=k+1;++i)
if(gcd(i,k-i+2).st==1) {
++cnt;
if(a1==-1||gcd(a1,a2).nd>gcd(i,k-i+2).nd) {
a1=i; a2=k-i+2;
}
}
cout<<cnt<<endl;
while(a1!=1||a2!=1) {
if(a1>a2) {
a1-=a2;
cout<<0<<" ";
}
else {
a2-=a1;
cout<<1<<" ";
}
}
cout<<endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |