Read an integer **N **that is the number of test cases. Each test case is a line containing two integer numbers **X **and **Y**. Print the sum of all odd values between them, not including **X **and **Y**.

## Input

The first line of input is an integer **N **that is the number of test cases that follow. Each test case is a line containing two integer **X **and **Y**.

## Output

Print the sum of all odd numbers **between****X and Y**.

Sample Input | Sample Output |

7
4 5 13 10 6 4 3 3 3 5 3 4 3 8 |
0
11 5 0 0 0 12 |

Solution:

#include <cstdio> int main(){ int n, i, f, x, j, s;scanf("%d", &n);while(n--){ s = 0;scanf("%d %d", &i, &f);if (i > f){ x = i; i = f; f = x; }i++;if (i % 2 == 0) i++;for (j = i; j < f; j += 2) s += j;printf("%d\n", s);} return 0; }

Advertisements