Advertisement
Negru_Diana

DENIS

Mar 5th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<fstream>
  4. using namespace std;
  5. ifstream fin("exp.in");
  6. ofstream fout("exp.out");
  7. double x[30004];
  8. int ap[30004];
  9. int main()
  10. {
  11. int n,m,i,d,aux,r,p,apd,ok=1;;
  12. fin>>m>>n;
  13. fout<<"1\n";
  14. for(i=1; i<=n; i++)
  15. {
  16. fin>>x[i];
  17. aux=x[i];
  18. r=sqrt(aux);
  19. d=2;
  20. while(aux>1)
  21. {
  22. p=0;
  23. while(aux%d==0)
  24. {
  25. p++;
  26. aux/=d;
  27. }
  28. ap[d]+=p;
  29. if(d*d<aux)
  30. {
  31. d++;
  32. }
  33. else
  34. {
  35. d=aux;
  36. }
  37. }
  38. }
  39. for(i=1; i<=30000; i++)
  40. {
  41. if(ap[i]%m==0 && ap[i])
  42. {
  43. fout<<i<<" "<<ap[i]/m<<'\n';
  44. }
  45. else
  46. {
  47. if(ap[i]%m)
  48. {
  49. fout.close();
  50. fout.open("exp.out",ios::out);
  51. fout<<"0";
  52. fout.close();
  53. fin.close();
  54. return 0;
  55. }
  56. }
  57. }
  58. fout.close();
  59. fin.close();
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement