Advertisement
yuawn

algo2017_week3_add_the_page

Oct 3rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define MAX 10000
  3. using namespace std;
  4.  
  5. vector<int> p;
  6.  
  7. void build(int max){
  8.     int a = 0;
  9.     for( int i = 1 ; i < max ; i++ ) {
  10.         a += i;
  11.         p.push_back( a );
  12.     }
  13. }
  14.  
  15. int main(){
  16.     build( MAX );
  17.     int t , n;
  18.     cin >> t;
  19.     while( t-- ){
  20.         cin >> n;
  21.         for( int i = 0 ; i < MAX ; i ++ ){
  22.             if( n == p[i] ) {
  23.                 cout << i + 2 << ' ' << i + 2 << endl;
  24.                 break;
  25.             }
  26.             else if( n < p[i] ) {
  27.                 cout << p[i] - n << ' ' << i + 1 << endl;
  28.                 break;
  29.             }
  30.         }
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement