Morass

Operators

Mar 22nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #define DEB printf("DEB!\n");
  5. #define D(X) cout<<"  "<<#X": "<<X<<endl;
  6. int N,S;
  7. using namespace std;
  8. bool rec(int u,int s){
  9.     if((s-1)==N)return u==S;
  10.     if(rec(u+s,s+1))return 1;
  11.     return rec(u-s,s+1);
  12. }
  13. int main() {
  14.     int cas;
  15.     cin>>cas;
  16.     while(cas--){
  17.         cin>>N>>S;
  18.         if(rec(1,2))
  19.             cout<<"Possible";
  20.         else cout<<"Impossible";
  21.         cout<<endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment