hdu_5104_素数表的应用
来源:互联网 发布:盐城大数据产业园官网 编辑:程序博客网 时间:2024/06/08 03:30
Primes Problem
Given a number n, please count how many tuple(p1, p2, p3) satisfied that p1<=p2<=p3, p1,p2,p3 are primes and p1 + p2 + p3 = n.
Input
Multiple test cases(less than 100), for each test case, the only line indicates the positive integer n(n≤10000).
Output
For each test case, print the number of ways.
Sample Input
3
9
Sample Output
0
2
Source
BestCoder Round #18
#include<iostream>#include<cstdio>#include<cstring>#include<map>using namespace std;typedef long long ll;int stu[11111]= {0,0,1};int num[11111];int main(){ int i,j,n; for(i=3; i<=10000; i++) { stu[i++]=1; stu[i]=0; } for(i=3; i<=10000; i++) for(j=i+i; j<=10000; j+=i) stu[j]=0; int k=0; for(i=1; i<=10000; i++) { if(stu[i]) num[k++]=i; } while(cin>>n) { map<int,int> q; q.clear(); int ans=0; for(i=0; num[i]<n; i++) { for(j=i; num[j]<n-num[i]; j++) { if(stu[n-num[i]-num[j]]&&n-num[i]-num[j]>=num[j]) ans++; } } cout<<ans<<endl; } return 0;}/*a s d f a s s */
阅读全文
0 0
- hdu_5104_素数表的应用
- 大素数的应用
- 素数的简单应用
- (数论 素数分布的应用)nefu 117 素数个数的位数(素数定理的位数公式)
- 求素数,求幂的应用
- 反素数的应用 hdu4228 zoj2562
- POJ3641 Pseudoprime numbers 素数测试的应用
- hdu(素数的简单应用)
- 素数与溢出在spark的应用
- 数素数--素数表的获取
- 求素数及素数表的获取
- 素数表的建立
- 素数的初始化表
- Relatives+水题+欧拉函数+素数打表的基本应用+poj
- 素数判断算法-----应用
- 算法应用-素数
- 反素数应用分析
- 素数测试应用
- 【异常和错误】PHP的异常和错误处理【原创】
- http range header
- Dubbo 回调用服务的处理逻辑
- 对于堆栈的疑问
- Alluxio 1.5.0开源发布版的技术亮点
- hdu_5104_素数表的应用
- jdbc之批处理
- 对于ie8和ie8一下版本不支持placeholder(文本框提示信息)的解决方案
- Windows PowerShell 2.0之服务管理
- 工作中的坑-----javabean属性命名
- UI自动化体系建设的创新实践
- 最后的战犯
- 九度1026:又一版A+B
- spring boot 使用thymeleaf 和shiro标签整合