标签:style http io ar color os sp for on
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 you know how many cigarettes can Tom has?
3 4 3 10 3 100 5
5 14 124
#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; }
标签:style http io ar color os sp for on
原文地址:http://blog.csdn.net/hdd871532887/article/details/41719091