Codeforces Round #617 (Div. 3), problem: (B) Food Buying 【math】

题意

给你 x 块钱,你花费多少会返回给你 x / 10 取整的前,问你最多能花费多少?

思路

数学题,按照题意所说模拟即可

code

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
int n,t;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    while(t--){
        ll x;
        cin>>x;
        ll num=0,ans=0;
        while(x>=10){
            num=x/10;
            x=x/10+x%10;
            ans+=num*10;
        }
        cout<<ans+x<<endl;
    }
    return 0;
}
学如逆水行舟,不进则退
发布了470 篇原创文章 · 获赞 1150 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/weixin_42429718/article/details/104178632