【題解】Codeforces 1296B. Food Buying

【題目敘述】https://codeforces.com/contest/1296/problem/B

#include <iostream>
using namespace std;
 
int t, n, ans, tmp;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        ans = n;
        while (n >= 10){
            tmp = n / 10;
            ans += tmp;
            n = n % 10 + tmp;
        }
        cout << ans << "\n";
    }
}
分享本文 Share with friends