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 when the number is combined, it is also NO. The reason is very simple. 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
# Include
# Include
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); continue;} if (vis [a]) printf (NO); 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); else printf (NO );}}} int main () {ace (); return 0 ;}