diff --git a/POJ/1276_funCfans.cpp b/POJ/1276_funCfans.cpp new file mode 100644 index 0000000..985b577 --- /dev/null +++ b/POJ/1276_funCfans.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +struct q +{ + int a,p; +}; +int cmp(const void *a,const void *b) +{ + return (*(q*)a).p-(*(q*)b).p; +} +int main() +{ + q qs[11]; + int cash,n,i,j,con[100001]; + char dp[100001]; + while(scanf("%d%d",&cash,&n)==2) + { + if(!n) + { + putchar('0');putchar('\n'); + continue; + } + for(i=0;i=qs[i].p;j--) + { + if(dp[j]) + { + if(con[j] && !dp[j-qs[i].p]) + { + con[j-qs[i].p]=con[j]-1; + dp[j-qs[i].p]=1; + } + con[j]=qs[i+1].a; + } + } + } + for(i=0;!dp[i];i++); + printf("%d\n",cash-i); + } + return 0; +}