Advertisement
a53

perfect1

a53
Jan 24th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. int F[8129];
  4.  
  5. bool div(int n)
  6. {
  7. int nr;
  8. for(int i=8128;n>1&&i>1;--i)
  9. {
  10. nr=0;
  11. while(F[i]&&nr<F[i]&&n%i==0)
  12. n/=i,++nr;
  13. }
  14. if(n==1)
  15. return true;
  16. return false;
  17. }
  18.  
  19. int main()
  20. {
  21. int n;
  22. ifstream f("perfect1.in");
  23. f>>n;
  24. int x;
  25. for(int i=1;i<=n;++i)
  26. f>>x,++F[x];
  27. ofstream g("perfect1.out");
  28. if(div(8128))
  29. {
  30. g<<8128;
  31. return 0;
  32. }
  33. if(div(496))
  34. {
  35. g<<496;
  36. return 0;
  37. }
  38. if(div(28))
  39. {
  40. g<<28;
  41. return 0;
  42. }
  43. if(div(6))
  44. {
  45. g<<6;
  46. return 0;
  47. }
  48. g<<"NU";
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement