a53

joc2020

a53
Feb 23rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define NR 1000005
  3. using namespace std;
  4. ifstream fin("joc2020.in");
  5. ofstream fout("joc2020.out");
  6. int n, x, K, P[NR];
  7. bitset <NR> viz;
  8.  
  9. void ciur()
  10. {
  11. for(int i = 2; i < NR; ++i)
  12. {
  13. if(viz[i] == 0)
  14. {
  15. P[++K] = i;
  16. for(int j = i+i; j < NR; j += i)
  17. viz[j] = 1;
  18. }
  19. }
  20. }
  21. int main()
  22. {
  23. ciur();
  24. fin>>n;
  25. for(int i=1; i<=n; i++)
  26. {
  27. fin>>x;
  28. int nd=1;
  29. for(int j = 1; j <= K && 1LL * P[j] * P[j] <= x; ++j)
  30. {
  31. if(x % P[j]) continue;
  32. int p = 0;
  33. while(x % P[j] == 0)
  34. {
  35. x /= P[j];
  36. ++p;
  37. }
  38. nd *= (p+1);
  39. }
  40. if(x>1)
  41. nd*=2;
  42. fout<<nd<<" ";
  43. }
  44. return 0;
  45. }
Add Comment
Please, Sign In to add comment