Advertisement
Combothermal

Untitled

Apr 10th, 2020
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. void solve() {
  2. cout << nl;
  3. ll N; cin >> N;
  4. if (N < 32) {
  5. F0R(i, N) {
  6. cout << i+1 << " " << i+1 << nl;
  7. }
  8. return;
  9. }
  10. N -= 32;
  11. bool full[32];
  12. F0Rd(i, 32) {
  13. if (N >= (1ll << i) - 1) {
  14. N -= (1ll << i) - 1;
  15. full[i] = true;
  16. } else full[i] = false;
  17. }
  18.  
  19. bool hi = false;
  20. F0R(i, 32) {
  21. if (!full[i]) {
  22. if (hi) {
  23. cout << i+1 << " " << i+1 << nl;
  24. } else {
  25.  
  26. cout << i+1 << " " << 1 << nl;
  27. }
  28. } else {
  29. F0R(j, i+1) {
  30. if (hi) {
  31. cout << i+1 << " " << i+1-j << nl;
  32. } else cout << i+1 << " " << j+1 << nl;
  33. }
  34. hi = !hi;
  35. }
  36. }
  37.  
  38.  
  39. F0R(i, N) {
  40. if (hi) {
  41. cout << 33+i << " " << 33+i << nl;
  42. } else {
  43. cout << 33+i << " " << 1 << nl;
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement