Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday 31 October 2016

P. Divisible by 3

Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/P

Score: 1

CPU: 1s
Memory: 512MB

Given N you have to find out the total number of integer between 0 to N is divisible by 3.

Input
First you will be given an positive integer T (1< T < 100), the number of test case. For each test case you will be given N ( 1 < N < 1000) in different lines.

Output
For each test case print “Case X: R”. Where X is the running test case number and R is the total amount of integer divisible by 3between 0 and N .

Sample

InputOutput
3 6 9 12Case 1: 3 Case 2: 4 Case 3: 5

Solution

#include<stdio.h>
int main()
{
    int count,n,i,j,t;
    scanf("%d",&t);
    for(j=1;j<=t;j++){
        count=0;
        scanf("%d",&n);
        for(i=0;i<=n;i++){
            if(i%3==0){
                count++;
            }
        }
        printf("Case %d: %d\n",j,count);
    }
    return 0;
}

No comments:

Post a Comment