Updated code

This commit is contained in:
Anthony Wang 2020-05-13 17:39:01 -05:00
parent 6835d0aab6
commit 75cdebec70
3 changed files with 7 additions and 7 deletions

View file

@ -11,14 +11,14 @@ int main() {
int N;
cin >> N;
if (N <= 500) {
// if N <= 500 then just use naïve method
if (N <= 31) {
// if N <= 31 then just use naïve method
for (int i = 0; i < N; ++i) cout << i + 1 << " " << 1 << '\n';
}
else {
// first we try to make N - 32
int sum = 0, side = 0, goal = N - 32;
for (int i = 0; i < 32; ++i) {
// first we try to make N - 31
int sum = 0, side = 0, goal = N - 31;
for (int i = 0; i < 31; ++i) {
cout << i + 1 << " " << (side ? i + 1 : 1) << '\n';
// each row sums to 2 ^ (i + 1)
@ -32,7 +32,7 @@ int main() {
else ++sum;
}
for (int i = 32; sum < N; ++i, ++sum) cout << i + 1 << ' ' << (side ? i + 1 : 1) << '\n';
for (int i = 31; sum < N; ++i, ++sum) cout << i + 1 << ' ' << (side ? i + 1 : 1) << '\n';
}
}
}

View file

@ -44,7 +44,7 @@ int main() {
reverse(r.begin(), r.end());
// Creates at most 2 * 99 + 50 * 98 = 5098 < 1e4 characters
// Creates at most ≈5000 < 10000 characters
cout << (ans ? l + m + r : "*") << '\n';
}
}