Advertisement
a53

NumarareSD

a53
Apr 18th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n,v[1005],cnt,sm[1005];
  4.  
  5. int numardiv(int nr)
  6. {
  7. int res=1;
  8. for(int i=2;i*i<=nr;++i)
  9. {
  10. int curr_sum=1,curr_term=1;
  11. while(nr%i==0)
  12. {
  13. nr=nr/i;
  14. curr_term*=i;
  15. curr_sum+=curr_term;
  16. }
  17. res*=curr_sum;
  18. }
  19. if(nr>=2)
  20. res*=1+nr;
  21. return res;
  22. }
  23.  
  24. int main()
  25. {
  26. ios_base::sync_with_stdio(0);
  27. cin.tie(0);
  28. cout.tie(0);
  29. cin>>n;
  30. for(int i=1;i<=n;++i)
  31. cin>>v[i],sm[i]=numardiv(v[i]);
  32. for(int i=1;i<n;++i)
  33. for(int j=i+1;j<=n;++j)
  34. if(sm[i]==sm[j])
  35. ++cnt;
  36. cout<<cnt;
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement