Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- bool arrayPrima[40000];
- int pastiPrima[5000];
- int prima,counter = 0, faktor = 0;
- long int n, num_factors, initial_n,power, loop;
- using namespace std;
- bool cekPrima(int);
- int main()
- {
- for (int i= 2; i<=39999; i++)
- {
- if (arrayPrima[i] == false)
- { prima = i;
- counter++;
- arrayPrima[prima] = true;
- pastiPrima[counter] = i;
- while (prima < 40000)
- {
- prima +=i;
- arrayPrima[prima - i] = true;
- }
- }
- else
- if (arrayPrima[i] == true)
- {
- arrayPrima[i] = false;
- continue;
- }
- }
- cin >> loop;
- while(loop--)
- {
- cin >> n;
- initial_n = n;
- num_factors = 1;
- for (long int i = 1; i <= counter; ++i)
- {
- power = 0;
- while (n % pastiPrima[i] == 0)
- {
- n = n / pastiPrima[i];
- ++power;
- }
- num_factors = num_factors * (power + 1);
- }
- if (n > 1)
- {
- num_factors = num_factors * 2;
- }
- if (num_factors >1 && num_factors < 5)
- cout << "YA" << endl;
- else
- cout << "TIDAK"<< endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment