证明应该是小凯的诱惑的升级版
应该可以用那个同余最短路来跑
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 }