Light OJ 1136 Division by 3 Solution in c cpp c++

Problem name: Division by 3

Problem number: 1136

Online Judge: Light OJ

Problem link: Light OJ 1136 Division by 3


Light OJ 1136 Division by 3 problem solution in C C++ CPP

Solution: 


#include <iostream>

#include <cmath>


using namespace std;


int main() {

    int testCase;

    cin >> testCase;

    for (int t = 0; t < testCase; t++) {

        int a, b, x, y, count;

        cin >> a >> b;

        (a - 1) % 3 == 0 ? x = ((a - 1) / 3) : x = ((a - 1) / 3) + 1;

        b % 3 == 0 ? y = (b / 3) : y = (b / 3) + 1;

        count = (b - y) - ((a - 1) - x);

        cout << "Case " << t + 1 << ": " << count << endl;

    }


    return 0;

}


Thumbnail: 

LightOJ 1136 Division by 3 solution
LightOJ 1136 Division by 3 solution

 




Tags: Light oj solution, lightoj 1136 solution, lightoj 1136 solution in c, lightoj 1136 solution in cpp, lightoj 1136 solution in c++, dabananda mitra, online judge solutions
Next Post Previous Post
No Comment
Add Comment
comment url