Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. int v[11];
  4. int divizori(int n)
  5. {
  6. int d=2, div=0;
  7. while(d*d<n)
  8. {
  9. if(n%d==0)
  10. div+=2;
  11. d++;
  12. }
  13. if(d*d==n)
  14. div++;
  15. return div;
  16. }
  17. int main()
  18. {
  19. ifstream fin("ciffrecv.in");
  20. ofstream fout("ciffrecv.out");
  21. int n, MAX=0, NR_AP=0;
  22. for(int i=1; i<=9; i++)
  23. v[i]=0;
  24. while(fin >> n)
  25. {
  26. if(divizori(n)==0)
  27. v[n]++;
  28. }
  29. if(v[2]!=0)
  30. {
  31. MAX=2;
  32. NR_AP=v[2];
  33. }
  34. if(v[3]!=0)
  35. {
  36. MAX=3;
  37. NR_AP=v[3];
  38. }
  39. if(v[5]!=0)
  40. {
  41. MAX=5;
  42. NR_AP=v[5];
  43. }
  44. if(v[7]!=0)
  45. {
  46. MAX=7;
  47. NR_AP=v[7];
  48. }
  49. fout<< MAX << " " << NR_AP;
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement