【題解】ZeroJudge e555: 10170 – The Hotel with Infinite Rooms

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=e555
【解題想法】模擬

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long S, D, cnt;
    while (cin >> S >> D){
        cnt = S;
        D -= S;
        while (D > 0){
            cnt++;
            D -= cnt;
        }
        cout << cnt << "\n";
    }
    return 0;
}
分享本文 Share with friends