| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 129490 | E869120 | Binary Subsequences (info1cup17_binary) | C++14 | 733 ms | 1348 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 <iostream>
#include <algorithm>
using namespace std;
bool used[1 << 20];
void init(int pos) {
	for (int i = 2; i <= pos; i++) {
		if (used[i] == true || pos%i != 0) continue;
		for (int j = i; j <= pos; j += i) used[j] = true;
	}
}
int main() {
	int T; cin >> T;
	for (int i = 1; i <= T; i++) {
		int A; cin >> A;
		
		for (int j = 1; j <= A + 2; j++) used[j] = false;
		init(A + 2);
		long long cnt = 0, ret = (1 << 30), mask = 0;
		for (int j = 1; j <= A + 2; j++) {
			if (used[j] == true) continue;
			cnt++;
			if (j > ((A + 2) >> 1) + 1) continue;
			int t1 = j, t2 = (A + 2) - j; long long mask1 = 0, lens = 0;
			while (t1 >= 1 && t2 >= 1) {
				if (t1 < t2) { t2 -= t1; }
				else { mask1 += (1LL << lens); t1 -= t2; }
				lens++; if (lens == 60) break;
			}
			if (ret > lens) {
				ret = lens; mask = mask1;
			}
		}
		cout << cnt << endl;
		for (int j = 0; j < ret - 1; j++) {
			if (j) cout << " "; cout << (mask / (1LL << j)) % 2;
		}
		cout << endl;
	}
	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... | ||||
