// 题意都不好理解 我以为是求 一个数被分成2个素数和  然后是求分成2个素数积
// 坑爹 忘记写 !=EOF 然后一直超时 然后换了几种 还是超时 一看别人代码 速度明显比我慢
// 然后发现被自己坑了 #include <iostream>
#include <math.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 10010
#define maxn 1000010
int gcd(int a,int b){
int r;
while(r=a%b){a=b;b=r;}
return b;
}
bool isp(int n){
if(n==) return true;
if(n%==||n==) return false;
int m=(int)(sqrt(n+1.0));
for(int i=;i<=m;i+=)
if(n%i==) return false;
return true;
}
int fun(int n){
int m,i;
if(n%==){
if(isp(n/))
return ;
else
return ;
}else{
int k;
m=(int)(sqrt(n+1.0));
k=;
for(i=;i<=m;i+=)
if(n%i==){
if(isp(i)&&isp(n/i))
{
return k=;
// printf("Yes\n");
break;
}
}
if(!k) return ; //printf("No\n");
}
}
int main()
{
int n;
int m;
int i,k; while(scanf("%d",&n)!=EOF){
if(fun(n)) printf("Yes\n");
else printf("No\n");
} return ;
}
// 郁闷 求出所有素数 还是不如上述快

#include <iostream>
#include <math.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 10010
#define maxn 1000010
int prim[maxn/],p;
bool f[maxn];
int gcd(int a,int b){
int r;
while(r=a%b){a=b;b=r;}
return b;
}
bool isp(int n){
if(n==) return true;
if(n%==||n==) return false;
int m=(int)(sqrt(n+1.0));
for(int i=;i<=m;i+=)
if(n%i==) return false;
return true;
}
int getprime(){
int i,j;
f[]=true;
for(i=;i<=maxn;i+=)
f[i]=true;
int m=(int)(sqrt(maxn+1.0));
for(i=;i<=m;i+=){
for(j=i*i;j<=maxn;j+=i)
f[j]=true;
}
for(i=;i<=maxn;i++)
if(!f[i]) prim[p++]=i;
}
int main()
{
int n;
int m;
int i,k;
getprime();
while(scanf("%d",&n)!=EOF){
m=(int)(sqrt(n+1.0));
k=i=;
while(prim[i]<=m){
if(n%prim[i]==&&!f[n/prim[i]])
{
k=;
break;
}
i++;
}
if(!k) printf("No\n"); else printf("Yes\n");
} return ;
}


zoj 2723 Semi-Prime的更多相关文章

  1. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  2. zoj 2723 Semi-Prime(素筛打表+搜索优化)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2723 题目描述: Prime Number Definitio ...

  3. ZOJ 3707 Calculate Prime S 数论

    思路:容易得到s[n]=s[n-1]+s[n-2],也就是fib数. 求第k小的fib质数的也就是第k个质数数-2,当k>2时. 在就是s[n]/x%m=s[n]%(x*m)/x. 代码如下: ...

  4. zoj 2723 Semi-Prime(set)

    Semi-Prime Time Limit: 2 Seconds      Memory Limit: 65536 KB Prime Number Definition An integer grea ...

  5. ZOJ - 3483 - Gaussian Prime

    先上题目: Gaussian Prime Time Limit: 3 Seconds      Memory Limit: 65536 KB In number theory, a Gaussian ...

  6. G - G ZOJ - 2723 (素数打表+set)

    Prime Number Definition An integer greater than one is called a prime number if its only positive di ...

  7. ZOJ 1457 Prime Ring Problem(dfs+剪枝)

     Prime Ring Problem Time Limit: 10 Seconds      Memory Limit: 32768 KB A ring is compose of n circ ...

  8. POJ 1595 Prime Cuts (ZOJ 1312) 素数打表

    ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=312 POJ:http://poj.org/problem?id=159 ...

  9. Prime Query (ZOJ 3911 线段树)

    Prime Query Time Limit: 1 Second Memory Limit: 196608 KB You are given a simple task. Given a sequen ...

随机推荐

  1. Follow Path -》 Unity3d通用脚本

    PathDefinition.cs using UnityEngine; using System.Collections; using System.Collections.Generic; usi ...

  2. Unity3D脚本中文系列教程(十一)

    http://dong2008hong.blog.163.com/blog/static/4696882720140313058768/ BoxCollider 类,继承自Collider 一个盒状的 ...

  3. POJ 1731

    #include<iostream> #include<string> #include<algorithm> using namespace std; int m ...

  4. [topcoder] EllysNumberGuessing

    http://community.topcoder.com/stat?c=problem_statement&pm=12975 简单题 #include <cstdlib> #in ...

  5. Visual StudioTools for Unity 使用技巧2

    在之前的博客介绍了 Visual Studio Tools for Unity的安装和使用. http://www.cnblogs.com/petto/p/3886811.html 其实这个工具还提供 ...

  6. PowerDesigner技巧

    原文:PowerDesigner技巧 1.PowerDesigner使用MySQL的auto_increment  ◇问题描述:  PD怎样能使主键id使用MySQL的auto_increment呢? ...

  7. Tomcat下的一些配置

    1. JAVA虚拟机性能优化,修改bin下的  catalina.sh/bat rem ----- Execute The Requested Command -------------------- ...

  8. 腾讯大讲堂ppt全集

    腾讯大讲堂ppt全集 腾讯大讲堂ppt全集资料下载 腾讯大讲堂ppt1-62资料下载 最新最全的腾讯大讲堂ppt全集 腾讯大讲堂ppt全集资料下载 腾讯大讲堂ppt1-62资料下载地址 http:// ...

  9. 1218. Episode N-th: The Jedi Tournament(bfs)

    1218 简答题 对于当前点 判断每个点是否可达 #include <iostream> #include<cstdio> #include<cstring> #i ...

  10. combination-sum-ii(熟悉下Java排序)

    代码还是这一块代码,但是还是写的很慢.. 其中用到了Java对 List的排序.查了很久,发现使用 Collections.sort 很方便. 另外对结果的去重,使用了 Java的HashSet. h ...