急求,全RE

P1021 [NOIP1999 提高组] 邮票面值设计

不能register i吧
by AC_Dolphin @ 2019-02-16 10:33:18


@[ACのDophin](/space/show?uid=90464) 为什么呢??试一下!
by ⚡GG⚡ @ 2019-02-16 10:39:18


@[ACのDophin](/space/show?uid=90464) 变成50分了:WA:2,AC:2
by ⚡GG⚡ @ 2019-02-16 10:40:54


至少要比刚刚好吧。。。你是把所有的register int i改成了int i吗
by AC_Dolphin @ 2019-02-16 10:56:22


@[ACのDophin](/space/show?uid=90464) yes
by ⚡GG⚡ @ 2019-02-16 10:57:26


代码: ```cpp #include<bits/stdc++.h> using namespace std; int a[210],ans[210],dp[55000]; int n,k,maxx=0; int sol(int m) { int i,j; memset(dp,63,sizeof(dp));dp[0]=0; for(i=1;i<=m;i++) for(j=a[i];j<=a[m]*n;j++) if(dp[j-a[i]]<n) dp[j]=min(dp[j],dp[j-a[i]]+1); int sum=0; while(dp[sum+1]<=100) sum++; return sum; } void dfs(int m) { if(m==k+1){ int t=sol(m-1); if(t>maxx){ maxx=t; memcpy(ans,a,sizeof(ans)); } return ; } int i; int t=sol(m-1); for(i=a[m-1]+1;i<=t;i++){ a[m]=i,dfs(m+1),a[m]=0; } } int main() { scanf("%d%d",&n,&k); a[1]=1; dfs(2); int i; for(i=1;i<=k;i++) printf("%d ",ans[i]); printf("\nMAX=%d\n",maxx); return 0; } ```
by ⚡GG⚡ @ 2019-02-16 10:58:13


你这个代码RE要么是数组开小要么是dfs爆栈
by Rbu_nas @ 2019-02-16 11:12:20


@[Rem°](/space/show?uid=80358) 那WA代码呢(现状)??
by ⚡GG⚡ @ 2019-02-16 11:13:00


@[垃圾一个](/space/show?uid=85933) 你有没有开O2,开了WA就是数组开小了显示成的是WA,没开那就是你算法需要改进咯
by Rbu_nas @ 2019-02-16 11:16:47


@[Rem°](/space/show?uid=80358) 没开,那里被卡了??
by ⚡GG⚡ @ 2019-02-16 11:18:21


| 下一页