fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4.  
  5. vector<int> v;
  6. bool poss(int s, int i)//poss stands for possible, in case its unclear
  7. {
  8. if(s==0)return true;
  9. if(i<0)return false;
  10. if(s>=v[i]+v[i-1])return poss(s-v[i]-v[i-1], i-2);
  11. if(s>=v[i])return poss(s-v[i], i-2)||poss(s-v[i-1], i-2);
  12. if(s>=v[i-1])return poss(s-v[i-1], i-2);
  13. return poss(s, i-2);
  14. }
  15.  
  16. #undef int
  17. int main()
  18. {
  19. #define int long long int
  20.  
  21. ios_base::sync_with_stdio(0);
  22. cin.tie(0);
  23. cout.tie(0);
  24.  
  25. int n;
  26. n = 32;
  27. v.resize(n);
  28. v[0] = 2, v[1] = 7;
  29. for(int i = 2;i<n;i++)
  30. {
  31. if(i&1)v[i] = v[i-1]+7;
  32. else v[i] = v[i-1]+3*v[i-2];
  33. }
  34. int t;
  35. cin>>t;
  36. while(t--)
  37. {
  38. cin>>n;
  39. if(poss(n, 31))cout<<"YES"<<endl;
  40. else cout<<"NO"<<endl;
  41. }
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty