Tarango

Untitled

Nov 19th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. int N;
  2. LL M;
  3. LL DP[105][256][256];
  4.  
  5. LL call(int cur,int sum1,int sum2){
  6.     if(cur > N){
  7.         if(sum1 <= sum2) return 1;
  8.         return 0;
  9.     }
  10.     if(DP[cur][sum1][sum2] != -1) return DP[cur][sum1][sum2];
  11.     LL res = 0;
  12.     res = (res + call(cur+1,sum1,sum2))%M;
  13.     res = (res + call(cur+1,sum1^cur,sum2))%M;
  14.     res = (res + call(cur+1,sum1,sum2^cur))%M;
  15.     return DP[cur][sum1][sum2] = res;
  16. }
  17.  
  18. int main() {
  19.     cin >> N >> M;
  20.     mems(DP,-1);
  21.     LL res = call(1,0,0);
  22.     res %= M;
  23.     cout << res << endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment