Submission #19779

#TimeUsernameProblemLanguageResultExecution timeMemory
19779suzy동전 (kriii4_E)C++98
5 / 100
8 ms1212 KiB
#include <stdio.h> #include <string.h> int d[1<<15], n; int f(int key) { if(key==0) return 0; if(d[key]>=0) return d[key]; int pre=0, lo=0; while(lo<n) { if( (key&(1<<lo))==0 ) { lo++; continue; } pre=lo; while( (key&(1<<lo)) && lo<n ) lo++; for(int i=1;i<(1<<(lo-pre));i++) { int flip=0; for(int j=pre;j<lo;j++) { if( (i&(1<<(j-pre))) ) flip+=(1<<j); } if(!f(key-flip)) return d[key]=1; } //printf("key = %d, lo = %d\n",key,lo); } return d[key]=0; } int main() { scanf("%d",&n); int res=0; memset(d,-1,sizeof(d)); for(int i=0;i<(1<<n);i++) { if(!f(i)) res++; } printf("%d",res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...