Advertisement
warrior98

Untitled

Jan 10th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define INF 0x3f3f3f3f
  3. #define NMAX 50005
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("fisier.in");
  8. ofstream fout("fisier.out");
  9.  
  10. int main() {
  11.     int n,i,curr,start=2,j;
  12.     long long gauss,e;
  13.  
  14.     fin>>n>>e;
  15.  
  16.     for(i=2,curr=0;i<=n+1;++i) {
  17.         if(1LL*(curr+1)*(curr+2)/2+n-i<=e)
  18.             ++curr;
  19.         else {
  20.             e-=1LL*curr*(curr+1)/2;
  21.             curr=0;
  22.  
  23.             for(j=i-1;j>start;--j) fout << j << ' ' << j-1<<'\n';
  24.             fout << start << " 1\n";
  25.             start = i;
  26.         }
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement