From: http://blog.csdn.net/svitter/
Question:
Determine whether an and an-1 are equal.
N is divided into two situations --
1. N is a prime number,
2. n is the sum.
= It seems like a piece of nonsense .. When a prime number is used, no can be directly output, because the prime number cannot be equal to an-1. If n is the power of a ^ B, then n is no. The reason is very easy. The minimum public factor of N in the previous number cannot exceed the power of N.
// ================================================ ==================================================================== // Name: number theory problems. CPP // Author: // version: // copyright: Your copyright notice // Description: Hello world in C ++, ANSI-style // ========================================== ========================================================== = # include <iostream> # include <stdio. h> # include <string. h> using namespace STD; # define LLn long int # define maxn 1000001 bool vis [maxn]; int prime [100000]; int P; void prime () {// 0 is not a combination, 1 is a combination of memset (VIS, 1, sizeof (VIS); P = 0; int I, j; for (I = 2; I <maxn; I ++) {If (vis [I]) {Prime [p ++] = I; for (j = 2 * I; j <maxn; J + = I) vis [J] = 0;} else continue;} void ACE () {// initprime (); // work pointint T, I; // numint A; int num; CIN> T; while (t --) {scanf ("% d", & A); if (a = 2) {printf ("NO \ n"); continue;} If (vis [a]) printf ("NO \ n"); else {num = 0; for (I = 0; I <= P; I ++) {if (a % prime [I] = 0) {num ++; while (a % prime [I] = 0) A/= prime [I];} if (a = 1) break;} If (Num> = 2) printf ("Yes \ n"); else printf ("NO \ n") ;}} int main () {ACE (); Return 0 ;}