caixukun___123 @ 2024-08-15 10:51:05
80分,求助
#include<bits/stdc++.h>
using namespace std;
vector<int> C;
void mul(vector<int> &A,int b){
int t=0,l=1;//l用来判断是否有前导零
for(int i=A.size()-1;i>=0;i--){
t=t*10+A[i];
if(t/b>0) l=0;
if(l==0) C.push_back(t/b);
t=t%b; //高精度除法
}
}
int main(){
string a;
int b;
vector<int> A;
cin>>a>>b;
for(int i=a.size()-1;i>=0;i--) A.push_back(a[i]-'0');
mul(A,b);
for(int i=0;i<C.size();i++) printf("%d",C[i]);
return 0;
}
by caixukun___123 @ 2024-08-15 10:53:39
help me!!!!!QwQ
by jza110228 @ 2024-08-15 10:58:31
b也用高精度试试
by caixukun___123 @ 2024-08-15 11:00:17
@jza110228 b的范围只有int,试过了,就是不过
by jza110228 @ 2024-08-15 11:00:24
b用longlong
by caixukun___123 @ 2024-08-15 11:01:41
@jza110228 谢谢,已经过了