Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- ifstream f("galeti.in");
- ofstream g("galeti.out");
- int n;
- f>>n;
- int64_t c;
- f>>c;
- int chain_length=1;
- int64_t current=n-1;
- while(current<c)
- current+=chain_length,++chain_length;
- int extra=-1;
- if(current>c)
- --chain_length,current-=chain_length,extra=c-current;
- int now=2+chain_length-1;
- while(now!=2+extra-1&&now!=1)
- g<<now<<' '<<now-1<<'\n',--now;
- if(extra>0)
- g<<2+chain_length<<' '<<now<<'\n';
- while(now!=1)
- g<<now<<' '<<now-1<<'\n',--now;
- int where=2+chain_length;
- if(extra>0)
- ++where;
- while(where<=n)
- g<<where<<' '<<1<<'\n',++where;
- f.close();
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement