001 #include "stdio.h"
002
003 int main() {
004 char line[100];
005
006 int num_cases
007 , i
008 , j
009 , k
010 , a
011 , b
012 , sum
013 ;
014
015 fgets(line, 100, stdin);
016 sscanf(line, "%d", &num_cases);
017
018 for (i = 1; i <= num_cases; i += 1) {
019 fgets(line, 100, stdin);
020 sscanf(line, "%d", &a);
021
022 fgets(line, 100, stdin);
023 sscanf(line, "%d", &b);
024
025 k = a & 1;
026 if (k == 0) {
027 a += 1;
028 }
029
030 for (j = a, sum = 0; j <= b; j += 2) {
031 sum += j;
032 }
033
034 printf("Case %d: %d\n", i, sum);
035 }
036
037 return 0;
038 }
Saturday, January 17, 2009
UVa problem 10783: sample code
Labels:
10783,
answer,
clue,
hint,
odd numbers,
Odd Sum,
problem,
sample algorithm,
sample code,
sample solution,
sum,
tip,
UVA Online Judge
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment