Sicily 14256. Pseudo Semiprime

14256. Pseudo Semiprime

Constraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

In number theory, a positive integer is a semiprime if it is the product of two primes. For example, 35 is a semiprime because 35 = 5 * 7, and both 5 and 7 are primes. A positive integer x is a pseudo semiprime if there is two
integers a and b such that a > 1, b > 1, a * b = x, and the greatest common divisor of a and b is 1.

Given an integer x, your task is to find out whether it is a pseudo semiprime.

Input

The input begins with a line containing an integer T (T<=100), which indicates the number of test cases. The following T lines each contain an integer x (1<=x<=1000000000).

Output

For each case, output YES if x is a pseudo semiprime; otherwise output NO.

Sample Input

415810

Sample Output

NONONOYES

Problem Source

SYSUCPC 2014 Preliminary (Online) Round

#include <stdio.h>
#include <string.h>

int gcd(int a, int b) {
	int temp;
	while (b) {
		temp = a % b;
		a = b;
		b = temp;
	}
	return a;
}

int main() {

	int caseNum;
	scanf("%d", &caseNum);
	while (caseNum--) {
		bool isOK = false;
		int x;
		scanf("%d", &x);
		for (int i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				if (gcd(i, x / i) == 1) {
					printf("YES\n");
					isOK = true;
					break;
				}
			}
		}
		if (!isOK) printf("NO\n");
	}

	return 0;
}
时间: 2024-08-03 00:54:12

Sicily 14256. Pseudo Semiprime的相关文章

POJ 3292 Semi-prime H-numbers(数)

Semi-prime H-numbers Description This problem is based on an exercise of David Hilbert, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that. An H-number is a positive number which is one more than a m

uva 11105 - Semi-prime H-numbers(数论)

题目链接:uva 11105 - Semi-prime H-numbers 题目大意:H-number为4?k+1(k为非负数),H-composites为因子中含有H-number(不包括自己本身)的数,反之久是H-prime,给定n,求有多少H-composites. 解题思路:首先用筛选法求出范围内的H-prime,然后枚举两个判断乘积是否在范围内. #include <cstdio> #include <cstring> const int maxn = 1e6+5; ty

Sicily 1146:Lenny&#39;s Lucky Lotto(dp)

题意:给出N,M,问有多少个长度为N的整数序列,满足所有数都在[1,M]内,并且每一个数至少是前一个数的两倍.例如给出N=4, M=10, 则有4个长度为4的整数序列满足条件: [1, 2, 4, 8], [1, 2, 4, 9], [1, 2, 4, 10], [1, 2, 5, 10] 分析:可用动态规划解题,假设dp[i][j],代表满足以整数i为尾数,长度为j的序列的个数(其中每一个数至少是前一个数的两倍).那么对于整数i,dp[i][j] 等于所有dp[k][j-1]的和,其中k满足:

Lou&#39;s Pseudo 3d Page

Lou's Pseudo 3d Page   (C) 2013 Louis Gorenfeld, updated May 3, 2013 NEW: Important details on the segmented road system and some additional links NEW: An (optional) explanation of finding field-of-view for the 3d projection formula NEW: An analysis

wifi mode: AP,Client,Ad-hoc,802.11s,Pseudo Ad-hoc(ahdemo),Monitor,AP(WDS),Client(WDS)

openwrt wifi mode:APClientAd-hoc802.11sPseudo Ad-hoc(ahdemo)MonitorAP(WDS)Client(WDS) http://forum.anywlan.com/thread-227622-1-1.htmlrepeater,bridge,wds,client+ap,wisp,station

sicily 1345 能量项链

先模拟一下确定理解题意,然后再找状态转移方程,注意方向~ 1 //sicily 1345 能量项链 2 #include <bits/stdc++.h> 3 4 using namespace std; 5 6 int a[205]; 7 int dp[205][205]; 8 9 int main() 10 { 11 int n; 12 while(cin >> n) 13 { 14 memset(dp, 0, sizeof(dp)); 15 for(int i=0; i<

sicily 1063. Who&#39;s the Boss

Time Limit: 1sec    Memory Limit:32MB Description Several surveys indicate that the taller you are, the higher you can climb the corporate ladder. At TALL Enterprises Inc. this "de facto standard" has been properly formalized: your boss is alway

Sicily 1735 Encryption (模拟)

链接:http://soj.me/show_problem.php?pid=1735&cid= Description Let me introduce an easy method of encryption to you. Suppose there're N bytes (1 byte = 8 bits) data that are to be encrypted and we want to encrypt them in groups of M bytes, while for the

sicily 1219(记忆化搜索)

题目链接:sicily 1214 解题思路: 博弈题,用搜索来做.但是,如果用普通的搜索来做的话,是会超时的--复杂度大约是O( n^n ),所以需要采用记忆化搜索的方法(其实差不多就是动态规划了,但是这里是树形DP). 状态: 用集合S表示现在树的状态,i 表示现在轮到谁进行砍边,dp[ S ][ i ]表示最优值.集合S可以用二进制来表示,即001表示现在还剩下第0条边. 状态转移: 1)A的目标是取最大值,B的目标是取最小值,我们在推导当前状态的最优解时,需要分两种情况考虑!即A得维护较大