#include #include using namespace std; int getgrundy(int x,vector& groundy,int K) { int subgame=0; if (x>K){ if (groundy[x]!=-1){ return groundy[x]; } subgame=x%(K+1);//grundyを求める }else{ subgame=K; } return groundy[x]=subgame; } int salve(vector data,int MAX,int K) { vector grundy(MAX+1,-1); vector Grundy(data.size()+1); int aw=0; for (int i=0;i>N>>K; vector data; int i; int MAX=0; int A; for (i=0;i>A; if (MAX