# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98431 | keko37 | Binary Subsequences (info1cup17_binary) | C++14 | 1026 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int t, n;
int f (int x, int y) {
int sol = 0;
while (y != 0) {
sol += x/y;
x = x % y;
swap(x, y);
}
if (x != 1) return INF; return sol;
}
void ispis (int x, int y) {
string s = "";
while (x != y) {
if (x > y) {
s += '0';
x -= y+1;
} else {
s += '1';
y -= x+1;
}
}
int len = s.size();
for (int i=len-1; i>=0; i--) {
cout << s[i] << " ";
}
cout << '\n';
}
void calc () {
int cnt = 0, mn = INF, ind;
for (int i=0; i<=n; i++) {
int val = f(i+1, n+1 - i);
if (val < INF) cnt++;
if (val < mn) {
mn = val;
ind = i;
}
}
cout << cnt << '\n';
ispis(ind, n - ind);
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> t;
for (int i=0; i<t; i++) {
cin >> n;
calc();
}
return 0;
}
컴파일 시 표준 에러 (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... |