Advertisement
skb50bd

UVa 10789 Odd Sum

Aug 28th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int T, high, low, i, sum;
  6.     cin >> T;
  7.     for(i = 1; i <= T; i++){
  8.         cin >> low >> high;
  9.         sum = 0;
  10.         (low % 2) ? low : low++;
  11.         while(low <= high) {
  12.             sum += low;
  13.             low += 2;
  14.         }
  15.         cout << "Case " << i << ": " << sum << endl;
  16.     }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement