fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int check(double a, double b){
  6. double x = a*b;
  7. double d = floor(x);
  8. if(x/d==1){
  9. return 1;
  10. }
  11. return 0;
  12. }
  13.  
  14. int main(){
  15. ios::sync_with_stdio(false);
  16. cin.tie(0);
  17. int n;
  18. cin >> n;
  19. double a[n];
  20. int count = 0;
  21. set<double> s;
  22. for(int i=0; i<n; i++){
  23. cin >> a[i];
  24. s.insert(a[i]);
  25. }
  26.  
  27. for(int i=0; i<n; i++){
  28. if(i==n-1)
  29. break;
  30. for(int j=i+1; j<n; j++){
  31. if(check(a[i],a[j])==1){
  32. count++;
  33. }
  34. }
  35. }
  36. int size = (int)s.size();
  37. if(size!=n){
  38. count = count - (n-size);
  39. }
  40. cout << count << "\n";
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 4292KB
stdin
11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001
stdout
8