A. Buying Torches

题目传送门

Buying Torches

题目大意

初始时你有一根木棍,你可以选择下列操作的一种:
1、用一根木棍换取x根木棍
2、用y根木棍换成一个炭
现在需要组成k根火炬(一根木棍一个炭),求最小操作数

思路

k根火炬需要的木棍数为 k + k ∗ y − 1 k+k*y-1 k+ky1,求用操作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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值