# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
19821 | | xhae | 동전 (kriii4_E) | C++14 | | 2 ms | 2748 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
const int mmod = 1000000007;
int prv[256][512]; // successive previous H, current grundy
int nxt[256][512];
int main()
{
int n;
cin >> n;
vector<int> grundy(1);
grundy[0] = 0;
for (int i=1; i<=n; i++) {
set<int> nxt;
for (int remain=0; remain<=i; remain++)
for (int i=0; i<=remain; i++)
nxt.insert(grundy[i] ^ grundy[remain - i]);
int ii = 0;
while (nxt.find(ii) != nxt.end()) ii ++;
grundy.push_back(ii);
}
// for (int i=0; i<=n; i++) printf("%d ", grundy[i]);
// printf("\n");
prv[0][0] = 1;
for (int i=0; i<=n; i++) {
for (int j=0; j<=i; j++)
for (int k=0; k<512; k++) {
if (i < n) {
// H
nxt[j+1][k] = (nxt[j+1][k] + prv[j][k]) % mmod;
}
{
// T
nxt[0][k^grundy[j]] = (nxt[0][k^grundy[j]] + prv[j][k]) % mmod;
}
}
for (int j=0; j<256; j++)
for (int k=0; k<512; k++) prv[j][k] = nxt[j][k], nxt[j][k] = 0;
}
printf("%d\n", prv[0][0]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |