|
|
back to boardWhat's wrong? 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; } |
|
|