URI / BEE CROWD 1132 - Multiples of 13 - Solution in C,C++,Python | URI - BEECROWD - BEE 1132 Solution in C,C++,Python

URI / BEE CROWD 1132 - Multiples of 13 - Solution in C,C++,Python | URI - BEECROWD - BEE 1132 Solution in C,C++,Python

                                                                                             beecrowd | 1132

Multiples of 13

Adapted by Neilor Tonin, URI  Brazil

                                                                                             Timelimit: 1


URI / BEE CROWD 1132 - Multiples of 13 - Solution in C,C++,Python | URI - BEECROWD - BEE 1132 Solution in C,C++,Python:

Write a program that reads two integer numbers X and Y and calculate the sum of all number not divisible by 13 between them, including both.

Input

The input file contains 2 integer numbers X and Y without any order.

Output

Print the sum of all numbers between X and Y not divisible by 13, including them if it is the case.

Input SampleOutput Sample

100
200

13954

N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1132 Solution in C :   

  URI / BEECROWD Online Judge 1132 Solve  in C :                                          

#include<stdio.h>
int main(){
    int X, Y, i;
    scanf("%d%d", &X,&Y);
    if (X > Y) {
        int total = 0;
        for (i = Y; i <= X; i++) {
            if (i % 13 != 0) {
                total += i;
            }
        }
        printf("%d\n", total);
    }else if(X < Y){
        int total2 = 0;
        for (i = X; i <= Y; i++) {
            if (i % 13 != 0) {
                total2 +=i;
            }
        }

        printf("%d\n", total2);
    }
   return 0;
}

0 Response to URI / BEE CROWD 1132 - Multiples of 13 - Solution in C,C++,Python | URI - BEECROWD - BEE 1132 Solution in C,C++,Python

Post a Comment