Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() {
- cout << nl;
- ll N; cin >> N;
- if (N < 32) {
- F0R(i, N) {
- cout << i+1 << " " << i+1 << nl;
- }
- return;
- }
- N -= 32;
- bool full[32];
- F0Rd(i, 32) {
- if (N >= (1ll << i) - 1) {
- N -= (1ll << i) - 1;
- full[i] = true;
- } else full[i] = false;
- }
- bool hi = false;
- F0R(i, 32) {
- if (!full[i]) {
- if (hi) {
- cout << i+1 << " " << i+1 << nl;
- } else {
- cout << i+1 << " " << 1 << nl;
- }
- } else {
- F0R(j, i+1) {
- if (hi) {
- cout << i+1 << " " << i+1-j << nl;
- } else cout << i+1 << " " << j+1 << nl;
- }
- hi = !hi;
- }
- }
- F0R(i, N) {
- if (hi) {
- cout << 33+i << " " << 33+i << nl;
- } else {
- cout << 33+i << " " << 1 << nl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement