hdu 4715 Difference Between Primes
来源:互联网 发布:软件打不开 编辑:程序博客网 时间:2024/05/22 10:50
http://acm.hdu.edu.cn/showproblem.php?pid=4715
#include<iostream>#include<stdio.h>#include <cmath>#include <algorithm>#include <string>#include <cstring>using namespace std;#define N 1000000bool isprm[N];long long xx[N];void isprime(){ int i,j,k=0; int s,e=sqrt( double(N) )+1; //sqrt是对于double数开平方 memset(isprm,1,sizeof(isprm)); isprm[0] = isprm[1] = 0; for(i=4 ; i < N; i=2+i) isprm[i]=0; for(i=3; i<e; i=2+i) if(isprm[i]) for(s=i*2,j=i*i; j<N; j=j+s) isprm[j]=0; //因为j是奇数,所以+奇数后是偶数,不必处理}int main(){ int coun=0; int i; isprime(); for(i=0; i<N; i++) if(isprm[i]) { xx[coun++]=i; } int T; long long t; long long t2; bool flag; scanf("%d",&T); while(T--) { scanf("%lld",&t); flag=false; for(i=0; i<coun; ++i) { t2=t+xx[i]; if(isprm[t2]) { flag=true; break; } } if(flag) { printf("%lld %lld\n",t2,xx[i]); } else { printf("FAIL\n"); } } return 0;}
0 0
- hdu 4715(Difference Between Primes)
- hdu 4715 Difference Between Primes
- hdu 4715Difference Between Primes
- hdu 4715 Difference Between Primes
- HDU 4715 Difference Between Primes
- HDU 4715 Difference Between Primes
- hdu 4715 Difference Between Primes
- hdu 4715 Difference Between Primes
- HDU 4715:Difference Between Primes
- hdu 4715 Difference Between Primes
- hdu 4715 Difference Between Primes acm
- hdu 4715 Difference Between Primes(stl)
- HDU 4715 Difference Between Primes 半个打表题。。
- hdu(4715) Difference Between Primes
- HDU 4715 Difference Between Primes (打表)
- hdu 4715 Difference Between Primes 筛法
- HDU 4715 Difference Between Primes (热身赛第十题)
- hdu 4715 Difference Between Primes (打表 枚举)
- leetcode——127—— Word Ladder
- hdu 4709 Herding
- linux 手动配置ip
- 《小强升职记》读书笔记
- 部分A+B,PAT,1016
- hdu 4715 Difference Between Primes
- 关于Win下“ImportError: No module named _curses”的解决方案
- android更新UI的几种方法
- Ubuntu使用中一些问题的解决办法备忘
- 研究生第二三课 软件工程&电子商务
- 面向对象表达式计算器源码分享
- iOS友盟第三方登录分享
- iOS - 计步器
- tornado入门 - session