#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
using namespace std;
constexpr static int MXLOG = 62;
int32_t main()
{
int k;
cin >> k;
vector<int> v;
vector<array<int, 2>> e;
int nxt = 1;
for (int i = 1; i <= 4; i++)
e.pb({0, nxt++});
v.pb(nxt-1);
for (int i = 1; i < MXLOG; i++)
{
for (int j = 0; j < 4; j++)
for (int l = 2; l <= 4; l++)
e.pb({nxt-l, nxt+j});
nxt+=3;
v.pb(nxt++);
}
for (int i = 0; i < 2; i++)
{
e.pb({nxt-1, nxt});
nxt++;
}
while (k != 0)
{
cout << k << "\n";
int i = 63 - __builtin_clzll(abs(k));
int s = -1;
if (i&1)
s = 1;
if (s == (abs(k) / k))
{
k -= (1<<i) * s;
e.pb({v[i], nxt-1});
}
else
{
k += (1<<(i+1)) * s;
e.pb({v[i+1], nxt-1});
}
}
nxt++;
cout << nxt << " " << e.size() << "\n";
for (auto [a, b] : e)
cout << (a+1) << " " << (b+1) << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=M] equals to -115, violates the range [0, 1000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=N] equals to -36, violates the range [1, 1000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=M] equals to -115, violates the range [0, 1000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=M] equals to -115, violates the range [0, 1000] |
2 |
Halted |
0 ms |
0 KB |
- |