SOJ3605 The sum of prime number
来源:互联网 发布:青少年计算机编程创业 编辑:程序博客网 时间:2024/05/16 06:06
好吧,其实是水题,但是我觉得其中还有一定的思维难度的。
#include <cstdio>#include <cstring>#include <cstdlib>#include <ctime>#include <climits>#include <cmath>#include <iostream>#include <string>#include <vector>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 1010;int T,n;bool vis[maxn];int p[maxn],pp;ll dp[maxn];int main(){ memset(vis,0,sizeof(vis)); for (int i=2;i<=1009;i++) for (int j=i*i;j<=1009;j+=i) vis[j]=1; pp=0; for (int i=2;i<=1009;i++) if (!vis[i]) p[pp++]=i; memset(dp,0,sizeof(dp)); dp[0]=1; for (int i=0;p[i]<=1000;i++) for (int j=p[i];j<=1000;j++) dp[j]+=dp[j-p[i]]; for (int i=0;p[i]<=1000;i++) dp[p[i]]--; dp[0]=0; scanf("%d",&T); while (T--) { scanf("%d",&n); printf("%lld\n",dp[n]); }return 0;}
- SOJ3605 The sum of prime number
- The sum of prime numbers
- Find the number of subsets such that the sum of numbers in the subset is a prime number
- [the summarization of algorithm]How to list the prime number
- Find the Prime Number
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Sum of Consecutive Prime Numbers
- Compute the sum number in PIC() clause of COBOL
- Problem 16 - What is the sum of the digits of the number 2^1000?
- sum of distinct number
- projecteuler网站第三题解法:Get the largest prime factor of a number
- Problem 7 of What is the 10 001st prime number?
- POJ 2739 Sum of Consecutive Prime Numbers
- Bitmap.Config
- Yii框架授权——accessRules用法
- 关于google code的SVN check out 失败的问题
- 再议:__cdecl与__stdcall 调用约定在动态链接库调用中不同的表现
- virtio-scsi的类,对象和实例
- SOJ3605 The sum of prime number
- android电子书大全 下载
- PAXOS---最重要的分布式算法----简单模拟
- http://acm.hdu.edu.cn/showproblem.php?pid=1020..
- 按键控制电源输出电路(妙不可言呀)
- Web工程师的工具箱
- BinarySearchTree
- 关于git的讨论记录
- 通过custom url scheme启动应用程序 下载、评价