36分求救

P1480 A/B Problem

syd190214 @ 2024-12-29 17:46:18

#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char c[100005];
ll b,x,n,a[100005],l1,s[100005];
int main(){
    cin>>c>>b;
    l1=strlen(c);
    for(int i=1;i<=l1;i++){
        s[i]=c[i-1]-48;
    }
    for(int i=1;i<=l1;i++){
        x=x*10+s[i];
        a[i]=x/b;
        x=x%b;
    }
    int p=1;
    for(int i=1;i<=l1;i++){
        if(a[i]==0){
            p++;
        }
    }
    for(int i=p;i<=l1;i++){
        cout<<a[i];
    }
    return 0;
}

悬棺


by syd190214 @ 2024-12-29 17:47:03

没错,我就是哪个在灌水区的蒟蒻


by computer11 @ 2024-12-29 18:33:01

送你个函数:

string BIGdivsmall(string na,int nb) {
    if (nb == 0) return "ERROR";
    int la = na.size();
    string ans = "";
    string now = "";
    for (int i = 0; i < la; i++) {
        now += na[i];
        int k = stoi(now);
        ans += (k / nb) + '0';
        k %= nb;
        now = to_string(k);
    }
    while (ans[0] == '0') ans.erase(0,1);
    return ans;
}

|