fork download
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. typedef vector<int> vi;
  6. typedef pair<int,int> pii;
  7. typedef pair<ll,int> pli;
  8. typedef pair<int,string> pis;
  9. double pi=3.1415926535898;
  10. #define speed ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  11. #define lop(i,n) for(int i=0;i<int(n);i++)
  12. #define ff(i,a,b) for(int i=a;i<=int(b);++i)
  13. #define fr(i,a,b) for(int i=a;i>=int(b);i--)
  14. #define ms(x,a) memset(x,a,sizeof(x))
  15. #define all(x) (x).begin(),(x).end()
  16. #define sz(x) int(x.size())
  17. #define pb push_back
  18. #define r0 return 0;
  19. #define CC continue;
  20. #define bb(x) cerr<< x <<endl;
  21. #define f first
  22. //#define s second // __builtin_popcount;
  23. //freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
  24. string ys = "YES\n";
  25. string no = "NO\n" ;
  26. const double EPS = 1e-6;
  27. const int inf = 1<<30;
  28. const ll M = 1e9+7 ;
  29. const int N = 100100;
  30. ///// for (int i= -inf ; i < inf ; i++) Hi :P
  31.  
  32. int mem[111][555];
  33. int dp (int n, int s)
  34. {
  35. if ( n == 0 )
  36. {
  37. return s != 0;
  38. }
  39. int &r = mem[n][s];
  40. if ( r != -1)
  41. {
  42. return r;
  43. }
  44. r = 0;
  45. ff(i,1,n)
  46. {
  47. r += dp(n-i,s^i);
  48. r %= M;
  49. }
  50. return r;
  51. }
  52.  
  53. main()
  54. {
  55. int t;ms(mem,-1);
  56. cin >> t;
  57. while(t--)
  58. {
  59. int n;
  60. cin >> n;
  61. cout << dp(n,0) << endl;
  62. }
  63.  
  64. }
Runtime error #stdin #stdout 0s 4200KB
stdin
Standard input is empty
stdout
Standard output is empty