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;
}

No comments:

Post a Comment