首页 > 代码库 > cigarette

cigarette

#include<iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		int WholeN,k,ciga;
		cin>>WholeN>>k;
		ciga=WholeN;
		while(WholeN/k>0)
		{
			ciga+=WholeN/k;
			WholeN=WholeN%k+WholeN/k;
		}
		cout<<ciga<<endl;




	}
}
 思想很简单,一次抽完所有烟,然后换新的烟,将留下的没有换的烟蒂和再次抽剩下的烟蒂相加再去换,直到无法再换