POJ 3132
来源:互联网 发布:在b站做网络直播有延迟 编辑:程序博客网 时间:2024/05/20 22:02
【题目分析】
素数筛+DP
【代码】
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;bool have[1201];int pri[1200],top=0;int dp[1121][15],n,m;int main(){ memset(have,false,sizeof have); for (int i=2;i<=1200;++i) { if (!have[i]) pri[++top]=i; for (int j=1;j<=top&&(pri[j]*i)<=1200;++j) {// cout<<"out"<<pri[j]*i<<" "<<endl; have[pri[j]*i]=true; if (i%pri[j]==0) break; } } memset(dp,0,sizeof dp); dp[0][0]=1; for (int i=1;i<=top;++i) for (int j=1120;j>=pri[i];--j) for (int k=1;k<=14;++k) dp[j][k]+=dp[j-pri[i]][k-1]; while (scanf("%d%d",&n,&m)!=EOF&&n&&m) printf("%d\n",dp[n][m]);}
0 0
- POJ 3132
- POJ 3132
- poj 3132简单dp
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- Js文件中调用其它Js函数的方法
- eclipse安装WindowBuilder
- 以ThreadStart方式实现多线程
- iOS 简单播放音效
- 了解 <script> 元素以及那些似曾相识但又不惹人注意的xxx
- POJ 3132
- 海量数据中找出出现次数最多的前10个URL
- Python中self的理解(二)
- Activity的启动
- python主函数
- HTTPS解析
- lua调用shell 脚本
- 数据结构-线性表-JAVA描述
- day14 python css position relative absolute