Tuesday, May 3, 2011

10783 - Odd Sum


#include<stdio.h>
int main()
{
    register long a,b,sum,i,t,k;
    //freopen("in.txt","r",stdin);
    scanf("%ld",&t);
    for(k=1;k<=t;k++)
    {
        scanf("%ld%ld",&a,&b);
        sum=0;
        if(!(a&1))a=a|1;
        for(i=a;i<=b;i=i+2)
            sum=sum+i;
        printf("Case %ld: %ld\n",k,sum);
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.