2018年1月13日 星期六

UVA Q10783 - Odd Sum

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long long int a,b,c,d;
cin>>a;
for(int x=1;x<=a;x++){
    cin>>b>>c;
    if(b%2==0){
        b++;
    }else if(c%2==0){
        c--;
    }
    d=0;
    for(int y=b;y<=c;y=y+2){
        d=d+y;
    }
    cout<<"Case "<<x<<": "<<d<<endl;
}


system("pause");
return 0;
}

沒有留言:

張貼留言