分手 | ||||||
| ||||||
Description | ||||||
静竹遇难,但数学却只寻思能挣扎在自己的密码学之中。
…此处省略一万字…
静竹认清了数学,自己的感情只有自己明白,一切都是过客,原来自己的心…
数学却只顾着自己的问题,苦苦研究,不想放弃,也许他解开了当下的问题,就会理睬静竹,就会安慰静竹的柔弱的心,你愿意帮助他们吗? | ||||||
Input | ||||||
每行输入一个整数n(0 < n <1000000), | ||||||
Output | ||||||
对于输入的整数n,如果n能够被分拆成两个素数的乘积,那么输出Yes,否则输出No | ||||||
Sample Input | ||||||
5 10 | ||||||
Sample Output | ||||||
No Yes | ||||||
Author | ||||||
万祥 |
解题思路:素数筛
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <stack>
#include <map>
#include <climits>
#include <functional>
using namespace std;
#define LL long long
const int INF=0x3f3f3f3f;
int n;
int a[1000090];
void init()
{
memset(a,1,sizeof a);
a[0]=a[1]=0;
for(int i=2;i<=1000000;i++)
{
if(a[i])
{
for(int j=2*i;j<=1000000;j+=i)
a[j]=0;
}
}
}
int main()
{
init();
while(~scanf("%d",&n))
{
int flag=0;
int k=sqrt(n);
for(int i=2;i<=k;i++)
{
if(a[i]&&n%i==0)
{
int m=n/i;
if(a[m]) flag=1;
}
}
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}