fork download
  1. #include <iostream>
  2. #include<cmath>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. int A, B;
  8. cin >> A >> B;
  9. long long all = 0;
  10. long long even = 0;
  11. long long odd = 0;
  12.  
  13. if (A > B) {
  14. swap(A, B);
  15. }
  16.  
  17. for (int i = A;i <= B;i++) {
  18. all +=i;
  19. if (i % 2 == 0)
  20. even +=i;
  21. else {
  22. odd +=i;
  23. }
  24. }
  25. cout << all << endl << even << endl << odd;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.41s 5316KB
stdin
Standard input is empty
stdout
162957038430244896
81478519357850144
81478519072394752