【luogu2737】 [USACO4.1]麦香牛块Beef McNuggets [动态规划 完全背包][数学 扩展欧几里德]...

证明应该是小凯的诱惑的升级版

应该可以用那个同余最短路来跑

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 #define rg register
 5 const int N=20,M=256*256+5;
 6 int n,pri[N],ans=0,pro[M+55];
 7 template <class t>void rd(t &x)
 8 {
 9     x=0;int w=0;char ch=0;
10     while(!isdigit(ch)) w|=ch=='-',ch=getchar();
11     while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
12     x=w?-x:x;
13 }
14 
15 int main()
16 {
17 //    freopen("nuggets.in","r",stdin);
18 //    freopen("nuggets.out","w",stdout);
19     rd(n);
20     memset(pro,0,sizeof(pro));pro[0]=1;
21     for(rg int i=1;i<=n;++i) rd(pri[i]),pro[pri[i]]=1;
22     for(rg int i=1;i<=n;++i)
23     for(rg int j=0;j<=M;++j)
24     if(pro[j]) pro[pri[i]+j]=1;
25     for(rg int i=M;i>=0;--i)
26     if(!pro[i]) {ans=i;break;}
27     if(ans>256*256) ans=0;
28     printf("%d",ans);
29     return 0;
30 }

转载于:https://www.cnblogs.com/lxyyyy/p/10808870.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值