Cigarettes time limit: theMs | Memory Limit:65535KB Difficulty:2
-
-
Describe
-
Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them
One by one keeping all the butts. Out of k > 1 butts He can roll a new cigarette.
Now,do know how many cigarettes can Tom have?
-
-
Input
-
First
-
input is a single Line,it's N and stands for there be n testdata.then there be n lines, each line contains T Wo integer numbers giving the values of N and K.
-
-
Output
-
-
for each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Pe TER can has.
-
-
Sample input
-
-
34 310 3100 5
-
-
Sample output
-
-
514124
-
-
Source
-
-
[Rooot] Original
-
-
Uploaded by
Rooot
#include <stdio.h>int main () {int test,n,k,t,ans;scanf ("%d", &test), while (test--) {scanf ("%d%d", &n, &k); Ans=n;while (n>=k) {t=n/k;ans+=t;n=n-t*k+t;} printf ("%d\n", ans);} return 0;}
Cigarettes (Nanyang oj94)