uva10783 Odd Sum

简介: uva10783 Odd Sum
#include <cstdio>usingnamespacestd;
intmain()
{
inttests;
scanf("%d", &tests);
for (inti=0; i<tests; i++)
    {
inta, b;
scanf("%d%d", &a, &b);
if (!(a&1))
a++;
if (!(b&1))
b--;
intnum= (b-a) /2+1;
printf("Case %d: %d/n", i+1, (a+b) *num/2);
    }
return0;
}
目录
相关文章
|
8月前
|
算法
uva 10891 game of sum
题目链接 详细请参考刘汝佳《算法竞赛入门经典训练指南》 p67
15 0
|
Go
HDOJ(HDU) 1977 Consecutive sum II(推导、、)
HDOJ(HDU) 1977 Consecutive sum II(推导、、)
89 0
|
算法
[LeetCode]--39. Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimit
1002 0
[LeetCode]--40. Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the
1268 0
[LeetCode]--15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not
1235 0
[LeetCode]--404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respective
951 0
|
Java
[LeetCode]--371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. Credits: Special thanks to @fujiaozhu for addin
1130 0
[LeetCode]--263. Ugly Number
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ug
829 0
[LeetCode]--112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tr
1218 0