Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int N;
- LL M;
- LL DP[105][256][256];
- LL call(int cur,int sum1,int sum2){
- if(cur > N){
- if(sum1 <= sum2) return 1;
- return 0;
- }
- if(DP[cur][sum1][sum2] != -1) return DP[cur][sum1][sum2];
- LL res = 0;
- res = (res + call(cur+1,sum1,sum2))%M;
- res = (res + call(cur+1,sum1^cur,sum2))%M;
- res = (res + call(cur+1,sum1,sum2^cur))%M;
- return DP[cur][sum1][sum2] = res;
- }
- int main() {
- cin >> N >> M;
- mems(DP,-1);
- LL res = call(1,0,0);
- res %= M;
- cout << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment