# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
19828 | | xhae | 동전 (kriii4_E) | C++14 | | 154 ms | 2744 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];
vector<int> grundy;
void run_init(int n)
{
for (int i=0; i<256; i++)
for (int j=0; j<512; j++)
prv[i][j] = nxt[i][j] = 0;
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;
}
if (j < n) {
// 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;
}
}
void run_grundy(int n)
{
for (int i=0; i<256; i++)
for (int j=0; j<512; j++)
prv[i][j] = nxt[i][j] = 0;
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;
}
}
int main()
{
int n;
cin >> n;
grundy.push_back(0);
for (int i=1; i<=n; i++) {
/* run_init(i);
int ii = 0;
while (prv[0][ii]) ii ++;
grundy.push_back(ii);*/
grundy.push_back(i);
}
/* for (int i=0; i<=n; i++) printf("%d ", grundy[i]);
printf("\n");
return 0;*/
run_grundy(n);
printf("%d\n", prv[0][0]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |