Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Uri/beecrowd problem no - 1099 solution in C

#include<stdio.h>
int main(){
    int N,X,Y,i,j,sum = 0;
    scanf("%d", &N);
    
    for(i = 1; i <= N; i++){
        scanf("%d%d", &X, &Y);
        if(X > Y){
            for(j = Y+1,sum = 0; j < X; j++){
                if(j % 2 != 0){
                    sum += j;
                }
            }
        }else if(X <= Y){
            for(j = X+1,sum = 0; j < Y; j++){
                if(j % 2 != 0){
                    sum += j;
                }
            }
        }
        printf("%d
", sum);
    }
    return 0;
}
Source by www.beecrowd.com.br #
 
PREVIOUS NEXT
Tagged: #problem #solution #C
ADD COMMENT
Topic
Name
5+1 =