let's start Code

1136 - Division by 3

                              1136 - Division by 3

                                                Explanation


#include<bits/stdc++.h>

using namespace std;


int cnt(int n)

{

    if(n == 0)return 0;

    int res = (n/3)*2;

    if(n%3 == 2)res += 1;

    return res;

}


int main()

{

    int t;

    cin >> t;

    for(int cs = 1; cs <= t; cs++){

        int a,b;

        cin >> a >> b;

        cout << "Case "<<cs << ": "<< cnt(b) -  cnt(a - 1) <<endl;

    }

    return 0;

}


Share:

No comments:

Post a Comment

About

let's start CODE

Popular Posts