Showing posts with label Chocolate Feast Hacker Rank Solution in C. Show all posts
Showing posts with label Chocolate Feast Hacker Rank Solution in C. Show all posts

Friday, 28 August 2020

Chocolate Feast Hacker Rank Solution in C

 https://www.hackerrank.com/challenges/chocolate-feast/problem


#include <stdio.h>

int main(){
    int t,noc,now; 
    scanf("%d",&t);
    for(int i = 0; i < t; i++){
        int n,c,m; 
        scanf("%d %d %d",&n,&c,&m);
        noc = n/c;
        now = noc;
        while(now>=m)
            {
            noc=noc+now/m;
            now=now/m+now%m;
        }
        printf("%d\n",noc);
    }
    return 0;
}