# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
19779 | | suzy | 동전 (kriii4_E) | C++98 | | 8 ms | 1212 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 <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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |