QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#380568 | #8508. DiviDuelo | Ganny | WA | 1ms | 3840kb | C++14 | 1.4kb | 2024-04-07 05:59:54 | 2024-04-07 05:59:56 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, int>> factorizacionPrima(long long numero) {
vector<pair<long long, int>> factoresPrimos;
for (long long i = 2; i * i <= numero; ++i) {
if (numero % i == 0) {
int exponente = 0;
while (numero % i == 0) {
++exponente;
numero /= i;
}
factoresPrimos.emplace_back(i, exponente);
}
}
if (numero > 1) {
factoresPrimos.emplace_back(numero, 1);
}
return factoresPrimos;
}
bool sumaExponentesEsPar(const vector<pair<long long, int>>& factoresPrimos) {
int sumaExponentes = 0;
for (const auto& factor : factoresPrimos) {
sumaExponentes += factor.second;
}
return sumaExponentes % 2 == 0;
}
int main() {
long long numero;
cin >> numero;
vector<pair<long long, int>> factoresPrimos = factorizacionPrima(numero);
bool sumaEsPar = sumaExponentesEsPar(factoresPrimos);
// for (const auto& factor : factoresPrimos) {
// cout << factor.first << "^" << factor.second << " ";
// }
if (factoresPrimos.size()%2==0 && numero != 1){
cout << "Y" << endl;
}else if (!sumaEsPar && numero%2 == 0){
cout << "Y" << endl;
}else{
cout << "N" << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
10
output:
Y
result:
ok "Y"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
9
output:
N
result:
ok "N"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1
output:
N
result:
ok "N"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
549755813888
output:
Y
result:
ok "Y"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
274877906944
output:
N
result:
ok "N"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3836kb
input:
847288609443
output:
N
result:
wrong answer 1st words differ - expected: 'Y', found: 'N'