题目传送门
题目大意
初始时你有一根木棍,你可以选择下列操作的一种:
1、用一根木棍换取x根木棍
2、用y根木棍换成一个炭
现在需要组成k根火炬(一根木棍一个炭),求最小操作数
思路
k根火炬需要的木棍数为 k + k ∗ y − 1 k+k*y-1 k+k∗y−1,求用操作1使得木棍数量不少于该数值的最小操作次数即可,最后加上k次换木炭就行
AC Code
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
#define int long long
#define debug(a) cout<<#a<<"="<<a<<endl;
// #define TDS_ACM_LOCAL
const int N=2e5 +9;
int x, y, k;
void solve(){
cin>>x>>y>>k;
x--;
int ans=k+k*y-1;
cout<<(ans+x-1)/x+k<<endl;
return ;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#ifdef TDS_ACM_LOCAL
freopen("D:\\VS code\\.vscode\\testall\\in.txt", "r", stdin);
freopen("D:\\VS code\\.vscode\\testall\\out.txt", "w", stdout);
#endif
int T;
cin>>T;
while(T--) solve();
return 0;
}