70分求助
查看原帖
70分求助
380118
Haroldyc楼主2020/11/24 19:28
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    long long n,res;
    long long  x,last_digit,i=1;
    cin >> n >> x;
    res = (n / 10) + ((n%10 >= x) ? 1 : 0);
    last_digit = n % 10;
    n /= 10;
    long long temp = last_digit;
    cout << res << '\n' << endl;
    for(n;n!=0;n/=10)
    {
        if(n/10==0)
        {
            if (n == x) { res += temp + 1; }
            else {
                res += ((n >= x) ? 1 : 0) * pow(10, i);
            }
            cout << res <<'\n'<< endl;
            break;
        }
        if (n%10== x) 
        { res += (n / 10) * pow(10, i); 
        res += temp + 1; 
        }  
        else {
            res += ((n / 10) + ((n%10 >= x) ? 1 : 0))*pow(10,i);
        }
       
        last_digit = n % 10;
        temp += pow(10, i) * last_digit;
     
        i++;
        cout << res << '\n' << endl;
    }
    cout << res << '\n' << endl;
    

    return 0;
}

检查了很多遍都没问题,但是只有70分,求大神帮忙

2020/11/24 19:28
加载中...