QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#380599#8508. DiviDueloGannyCompile Error//C++141.4kb2024-04-07 06:20:582024-04-07 06:20:59

Judging History

你现在查看的是最新测评结果

  • [2024-04-07 06:20:59]
  • 评测
  • [2024-04-07 06:20:58]
  • 提交

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 && factoresPrimos.size()%!=2 && factoresPrimos.size()<2){
        cout << "Y" << endl;
    }else{
        cout << "N" << endl;
    }

    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:46:51: error: expected primary-expression before ‘!=’ token
   46 |     }else if (!sumaEsPar && factoresPrimos.size()%!=2 && factoresPrimos.size()<2){
      |                                                   ^~