Advertisement
a53

galeti

a53
Jan 31st, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. ifstream f("galeti.in");
  7. ofstream g("galeti.out");
  8. int n;
  9. f>>n;
  10. int64_t c;
  11. f>>c;
  12. int chain_length=1;
  13. int64_t current=n-1;
  14. while(current<c)
  15. current+=chain_length,++chain_length;
  16. int extra=-1;
  17. if(current>c)
  18. --chain_length,current-=chain_length,extra=c-current;
  19. int now=2+chain_length-1;
  20. while(now!=2+extra-1&&now!=1)
  21. g<<now<<' '<<now-1<<'\n',--now;
  22. if(extra>0)
  23. g<<2+chain_length<<' '<<now<<'\n';
  24. while(now!=1)
  25. g<<now<<' '<<now-1<<'\n',--now;
  26. int where=2+chain_length;
  27. if(extra>0)
  28. ++where;
  29. while(where<=n)
  30. g<<where<<' '<<1<<'\n',++where;
  31. f.close();
  32. g.close();
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement