fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main(){
  5.  
  6. static const int Target = 2014;
  7. std::vector<std::pair<int, int>> vec;
  8. std::size_t Val = 0;
  9. int T = (Target / 5 * 3);
  10.  
  11. for (int i = 0; i < T; i++){
  12. Val = 0;
  13. for (int j = i; j < T; j++){
  14. Val += j;
  15. if (Val == Target) vec.push_back(std::make_pair(i, j));
  16. if (Val>Target)break;
  17. }
  18. }
  19.  
  20. std::cout << "I found " << vec.size() << " count!!" << std::endl;
  21.  
  22. for (auto& o : vec){
  23. std::cout << o.first << " to " << o.second << std::endl;
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
I found 3 count!!
12 to 64
97 to 115
502 to 505