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 <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
const int MOD = 1e9+7;
const int MAX_N = 44721;
int K;
int tri[MAX_N+1];
int cnt[MAX_N+1];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> K;
for (int i = 1; i <= MAX_N; i++) {
tri[i] = i*(i+1)/2;
}
int N = 1;
for (int i = MAX_N; i >= 1; i--) {
cnt[i] = K / tri[i];
N += i*cnt[i];
K %= tri[i];
}
cout << N << "\n";
cout << 0 << " " << -1 << "\n";
int curVal = 0;
for (int i = 1; i <= MAX_N; i++) {
for (int j = 1; j <= cnt[i]; j++) {
for (int k = 1; k <= i; k++) {
curVal++;
if (k == 1) {
cout << curVal << " " << 0 << "\n";
continue;
}
cout << curVal << " " << curVal-1 << "\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... |