ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1355. Bald Spot Revisited

What's wrong?
Posted by Avyatkin 26 Nov 2018 18:41
Wrong answer on test 4:



#include<iostream>

using namespace std;

//Разложение на простые множители числа n
unsigned long long int PrimeFactorization(unsigned long long n)
{
    unsigned long long int k(0);
    unsigned long long int m = (int)sqrt(n) + 1;

    for (int i(2); i <= m; i++)
    {
        if (n%i == 0)
        {
            while (n%i == 0)

            {
                n /= i;
                k++;
            }
        }
        if (n > 1 && i == m - 1)
        {
            k++;
        }
    }
    return k;
}


int main()
{
    setlocale(LC_ALL, "rus");
    unsigned long long int a, b;
    int n;
    cin >> n;

unsigned long long int* ans = new unsigned long long int[n];

    for (int i(0); i < n; i++)
    {
        cin >> a >> b;
        if ((b%a) == 0)
        {
                ans[i] = PrimeFactorization(b/a) + 1;
        }
        else ans[i] = 0;
    }

    for (int i(0); i < n; i++)
    {
        cout << ans[i] << endl;
    }
    if (n == 0) cout << 0;

    return 0;
}