欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

背包问题 tyvj1172

发布时间:2025/3/14 编程问答 38 豆豆
生活随笔 收集整理的这篇文章主要介绍了 背包问题 tyvj1172 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

tyvj日常挂……,改日再测评

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int n; 7 unsigned int f[4010]; 8 int main(){ 9 scanf("%d",&n); 10 memset(f,0,sizeof(f)); 11 f[0]=1; 12 for(int i=1;i<=n;i++) 13 for(int j=i;j<=n;j++) f[j]+=f[j-i];//unsigned int 自然溢出等价于取模 14 printf("%u",f[n]-1); 15 return 0; 16 }

 

转载于:https://www.cnblogs.com/sdfzxh/p/7153233.html

总结

以上是生活随笔为你收集整理的背包问题 tyvj1172的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。