Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created May 27, 2014 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsrinivas/1d4a17edd0d6621450b0 to your computer and use it in GitHub Desktop.
Save zsrinivas/1d4a17edd0d6621450b0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <ctype.h>
int main(int argc, char const *argv[])
{
int n,c,m,choc=0,upchoc=0;
int testc,*pint=&upchoc,wrappers;
scanf("%d", &testc);
while(testc--)
{
choc=0;
scanf("%d%d%d", &n,&c,&m);
choc=n/c;
upchoc=choc;
wrappers=upchoc;
while(wrappers>=m)
{
upchoc=wrappers/m;
wrappers-=(upchoc)*m;
wrappers+=upchoc;
choc+=upchoc;
}
printf("%d\n", choc);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment