题目
题目描述
比较好读懂,就不翻译了。
解析
分两步,首先产生sticks,然后产生coal。算出需要sticks的总数:
a
n
=
a
n
−
1
+
x
−
1
a
n
=
1
+
(
n
−
1
)
∗
(
x
−
1
)
=
k
(
y
+
1
)
n
=
k
∗
(
y
+
1
)
−
1
x
−
1
a_n=a_{n-1}+x-1 \\ a_n=1+(n-1)*(x-1)=k(y+1) \\ n=\frac{k*(y+1)-1}{x-1}
an=an−1+x−1an=1+(n−1)∗(x−1)=k(y+1)n=x−1k∗(y+1)−1
最后再加上k(用于产生coal)即可。
代码
#include <iostream>
#include <map>
using namespace std;
#define ll long long
int main(){
ios::sync_with_stdio(false);
int T;cin>>T;
while(T--){
ll x,y,k;
cin>>x>>y>>k;
ll tot=k*y+k;
tot--;
ll nt=tot%(x-1)==0?tot/(x-1):(tot/(x-1))+1;
ll ans=nt+k;
cout<<ans<<endl;
}
}