fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. std::vector<double> A({0.1,0.15,0.25,0.29,0.35,0.55,0.65,0.85,1.15,1.44,1.46,1.59,1.88,2.01,2.04,2.05,3.01});
  9. size_t i=0, j=A.size()-1;
  10. int result = 0;
  11. if (A[j] <= 2) return 0;
  12. while (i != j) {
  13. if (A[i]*A[j]>A[i]+A[j]) {
  14. result += j-i;
  15. cout << A[i] << " to " << A[j] << " for a total of " << result << endl;
  16. --j;
  17. } else {
  18. ++i;
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1.59 to 3.01 for a total of 5
2.01 to 2.05 for a total of 7
2.01 to 2.04 for a total of 8