[向上取整的公式] Educational Codeforces Round 95 (Rated for Div. 2) A. Buying Torches

题目:http://codeforces.com/contest/1418/problem/A

设需要a次1操作,则等式为 1+a*(x-1)=tot=k+k*y, a次1操作得到足够的s,再进行k次2操作,所以答案是a+k

化简为:

 这里需要用到向上取整公式

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define endl '
'
#define V vector
#define pb(x) push_back(x);
const ll amn=1e5+5;
ll a[amn];
int main(){
//    cout<<ceil(0.1);
    ios::sync_with_stdio(0);
    ll T=1;
    cin>>T;
    while(T--){
        ll x,y,k;
        cin>>x>>y>>k;
        cout<<(k*(y+1)-1+x-1-1)/(x-1)+k<<endl;
    }
}
原文地址:https://www.cnblogs.com/Railgun000/p/13816744.html