-
Notifications
You must be signed in to change notification settings - Fork 0
/
light_more_light.cpp
98 lines (95 loc) · 2.56 KB
/
light_more_light.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Made by: Romeu I. L. Pires
for "Special topics in programming" course
in UFRJ (Universidade Federal do Rio de Janeiro),
on 2019.1 semester
- Problem PDF:
https://uva.onlinejudge.org/external/101/10110.pdf
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
vector<long long> primes;
vector<long long> crivo;
void fillPrimes( size_t crivo_size ){
crivo.clear(); crivo.resize(crivo_size);
crivo[0] = 1;
for( size_t i = 1 ; i < crivo_size ; i++ ){
if( crivo[i] == 0 ){
primes.push_back(i+1);
for( size_t j = i + (i+1) ; j<crivo_size ; j+=(i+1) )
crivo[j] = 1;
}
}
}
map<long long,int> factored( long long N ){
map<long long,int> ret;
if( N <= 1 ) return ret;
long long sqrt = pow(N,0.5) + 1;
for( auto it = primes.begin() ; it != primes.end() && *it < sqrt && N != 1 ; it++ ){
while( N % *it == 0 ){
ret[*it]++;
N = N / *it;
sqrt = pow(N,0.5)+1;
}
}
if( N != 1 ) ret[N]++;
return ret;
}
bool evenDivisors( long long N ){
long long sqrt = pow(N,0.5) + 1;
for( auto it = primes.begin() ; it != primes.end() && *it < sqrt && N != 1 ; it++ ){
int this_exp = 0;
while( N % *it == 0 ){
N = N / *it;
this_exp++;
}
if( this_exp > 0 )
sqrt = pow(N,0.5)+1;
if( this_exp % 2 == 1 ) return true;
}
if( N != 1 ) return true;
return false;
}
long long numberOfDivisor( long long N ){
map<long long,int> factors = factored(N);
long long ret = 1;
for( auto it : factors )
ret *= (it.second + 1);
return ret;
}
vector<long long> divisors( long long N ){
vector<long long> ret;
map<long long,int> factors = factored(N);
ret.push_back(1);
for( auto it = factors.begin() ; it != factors.end() ; it++ ){
vector<long long> to_add;
for( long long e = 0 ; e < it->second ; e++ )
for( auto div : ret )
to_add.push_back( div * pow(it->first,e) );
for( auto div : to_add )
ret.push_back(div);
}
return ret;
}
int main(){
#ifndef ONLINE_JUDGE
ifstream cin("entrada.txt");
ofstream cout("saida.txt");
#endif
// ==========
fillPrimes(65536);
long long N;
while( cin >> N && N != 0 ){
long long x = sqrt(N);
if( N != x * x )
cout << "no" << endl;
else
cout << "yes" << endl;
}
}