#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; } }思想非常easy。一次抽全然部烟,然后换新的烟。将留下的没有换的烟蒂和再次抽剩下的烟蒂相加再去换,直到无法再换