UVa 10783 Odd Sum (water ver.)
来源:互联网 发布:php v phpinfo 编辑:程序博客网 时间:2024/05/20 03:38
10783 - Odd Sum
Time limit: 3.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=19&page=show_problem&problem=1724
Given a range [a, b], you are to find the summation of all the odd integers in this range. For example, the summation of all the odd integers in the range [3, 9] is 3 + 5 + 7 + 9 = 24.
Input
There can be at multiple test cases. The first line of input gives you the number of test cases, T ( 1T100). Then T test cases follow. Each test case consists of 2 integers a and b ( 0ab100) in two separate lines.Output
For each test case you are to print one line of output - the serial number of the test case followed by the summation of the odd integers in the range [a, b].Sample Input
21535
Sample Output
Case 1: 9Case 2: 8
完整代码:
/*0.006s*/#include <cstdio>int main(void){int t, a, b;scanf("%d", &t);for (int i = 1; i <= t; ++i){scanf("%d%d", &a, &b);a >>= 1, b = (b + 1) >> 1;printf("Case %d: %d\n", i, b * b - a * a);}return 0;}
- UVa 10783 Odd Sum (water ver.)
- UVa 12640 Largest Sum Game (water ver.)
- UVa 10656 Maximum Sum (II) (water ver.)
- UVa 10783 - Odd Sum
- UVA 10783 - Odd Sum
- UVa 10783-Odd Sum
- UVa 10082 WERTYU (water ver.)
- UVa 10696 f91 (water ver.)
- UVa 79 ClockHands (water ver.)
- UVa 11340 Newspaper (water ver.)
- UVa 514 Rails (water ver.)
- UVa 11150 Cola (water ver.)
- UVa 10300 Ecological Premium (water ver.)
- UVa 414 Machined Surfaces (water ver.)
- UVa 490 Rotating Sentences (water ver.)
- UVa 445 Marvelous Mazes (water ver.)
- UVa 488 Triangle Wave (water ver.)
- UVa 457 Linear Cellular Automata (water ver.)
- [每日一题] 11gOCP 1z0-052 :2013-09-13 FAST_START_MTTR_TARGET.........................................A69
- reverse Integer
- 华为机考(待续)
- linux 下各errno的意义
- HDOJ 2955 Robberies 简单01背包+简单概率思想
- UVa 10783 Odd Sum (water ver.)
- 虚拟机克隆
- android adb shell 命令大全
- c语言转义字符集
- batman.js 结合rails 入门
- 内核编译选项 M选项的操作
- 服务器程序的设计方法
- PHP实现分页
- 排序系列之一冒泡排序