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