All pastes #207776 Raw Edit

Rave Hanker

public cpp v1 · immutable
#207776 ·published 2006-10-18 05:59 UTC
rendered paste body
#include <cstdio>#include <cmath>#include <algorithm>using namespace std;#define DBG#ifdef DBG#define DP(x) {x}#else#define DP(x) #endif#define FOR0(i, n) for ( typeof(n) i=0;  i<n; i++)const int SZ = 101;const long PSZ = 1000009;long int Primes[PSZ];long int PrLen;void findPrimes(long int n){    PrLen = 1;    Primes[0] = 2;    for (long int i=Primes[0]+1; i<n; i++) {        bool isPrime =true;        FOR0(j, PrLen) {            if (i%Primes[j] == 0) {                isPrime = false;                break;            }        }        if (isPrime) {            Primes[PrLen++]=i;        }    }}int main(){    int c;    long inp[SZ];    long M;    scanf("%d", &c);    M = 0;    FOR0(i, c) {        scanf("%ld", &inp[i]);        M = max (M, inp[i]);    }    PrLen = 0;    findPrimes((long)sqrt(M));    DP(FOR0(i, PrLen) fprintf(stderr, "%ld ", Primes[i]);fprintf(stderr,"\n");)        FOR0(i, c) {            bool OK=true;            DP(fprintf(stderr,"Inp : %ld\n", inp[i]););            FOR0 (j, PrLen) {                long times;                if ( ( (Primes[j]%4) != 3) || !OK)                    continue;                DP(fprintf(stderr,"Prime : %ld num : %ld\n", Primes[j], inp[i]););                for (times = 0; (inp[i] != 0) && ( inp[i]%Primes[j]==0); times++) {                    inp[i] /= Primes[j];                }                DP(fprintf(stderr,"times :%ld\n", times););                if (times%2 != 0) {                    OK = false;                }            }            if (OK)                printf("Yes\n");            else                 printf("No\n");        }    return 0;}