Monday, March 17, 2014

UVa Solution 10783 : Odd Sum

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    long long a, b, test, i, t, sum;
    scanf("%lld", &test);
    for(t=1; t<=test; t++)
    {
        scanf("%lld%lld", &a, &b);
        sum=0;
        for(i=a; i<=b; i++)
        {
            if(i%2 !=0)
            {
                sum=sum+i;
            }
        }
        printf("Case %lld: %lld\n", t, sum);
    }
    return 0;
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...