Advertisement
ItsPossible

Untitled

Dec 14th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
  5. #define pb push_back
  6. #define mp make_pair
  7. #define f first
  8. #define sz size()
  9. #define s second
  10. #define pii pair<int, int>
  11. #define all(s) s.begin(), s.end()
  12. #define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
  13. #define inf INT_MAX  
  14. #define int ll
  15.  
  16. using namespace std;
  17.  
  18. const int maxn = 1e5 + 100;
  19. const int mod = (int)1e9 + 7;
  20. const int maxlog = (int)20;
  21. const int P = mod;
  22.  
  23. main () {
  24.   Add_Speed;
  25.   file("B");  
  26.   int tt;
  27.   cin >> tt;
  28.  
  29.   while(tt--){
  30.     int n;
  31.     ll a1;
  32.     cin >> n >> a1;
  33.     ll val = n * (1ll << (n - 1)) + 1;
  34.     //cout << (1ll << (n - 1)) << endl;
  35.     if(n == 1){
  36.       cout << a1 << endl;
  37.       continue;
  38.     }
  39.     if(a1 % val != 0){
  40.       cout << "-1\n";
  41.       continue;
  42.     }
  43.     ll dif;
  44.     if(n == 2) dif = 4;
  45.     if(n == 3) dif = 6;
  46.     else dif = n * 1ll * (1ll << (n - 2));
  47.     dif *= a1 / val;
  48.     cout << a1 << " ";
  49.     for(int i = 2; i <= n; i++){
  50.       ll x = a1, ans = x - dif;
  51.       cout << ans << " ";
  52.       a1 = ans;
  53.       dif /= 2;
  54.     }
  55.     cout << endl;
  56.   }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement