80pts代码在线求调(玄关
查看原帖
80pts代码在线求调(玄关
1108078
nothing_exe_studio楼主2024/6/9 21:40
#include <bits/stdc++.h>
using namespace std;
long long N;
int A, B, len;
int a[25];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> N >> A >> B;
    while (N) {
        a[++len] = N % 10;
        N /= 10;
    }
    for (int i = len; i >= 1; i--) {
        if (a[i] < 9) {
            int to9 = 9 - a[i]; 
            int to0 = a[i] + 1; 
            if (to9 <= A) {
                A -= to9;
                a[i] = 9;
            } else if (to0 <= B) { 
                B -= to0;
                a[i] = 9;
            } else if (A >= to9) {  
                A -= to9;
                a[i] = 9;
            } else { 
                a[i] += A;
                A = 0;
            }
        }
    }
    for (int i = len; i > 0; i--) cout << a[i];
    return 0;
}
2024/6/9 21:40
加载中...