Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- #define DEB printf("DEB!\n");
- #define D(X) cout<<" "<<#X": "<<X<<endl;
- int N,S;
- using namespace std;
- bool rec(int u,int s){
- if((s-1)==N)return u==S;
- if(rec(u+s,s+1))return 1;
- return rec(u-s,s+1);
- }
- int main() {
- int cas;
- cin>>cas;
- while(cas--){
- cin>>N>>S;
- if(rec(1,2))
- cout<<"Possible";
- else cout<<"Impossible";
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment