RE求助

P1480 A/B Problem

Kagasu_ACGODs_KA @ 2024-10-18 20:10:42

#include<bits/stdc++.h>
using namespace std;
struct bignum{
    int num[100010]={};
    int len;
}a,c;
int b;
string sa,sb;
void mydiv(bignum &a,int &b,bignum &ans){
    int tmp=0;
    bool flag=1;
    for(int i=0;i<a.len;i++){
        tmp=tmp*10+a.num[i];
        if(flag){
            if(tmp/b) ans.num[ans.len]=tmp/b,ans.len++,tmp%=b,flag=0;
        }
        else ans.num[ans.len]=tmp/b,ans.len++,tmp%=b;
    }
    if(ans.len==0) ans.len=1;
}
int main(){
    cin>>sa>>sb;
    a.len=sa.length();
    for(int i=0;i<sa.length();i++) a.num[i]=sa[i]-'0';
    cin>>b;
    mydiv(a,b,c);
    for(int i=c.len-1;i>=0;i--) cout<<c.num[i];
    return 0;
}
Runtime Error.
Received signal 8: Floating-point exception

bdfs无果,把代码喂给AI得到的全都是wyy,球球了


by Kagasu_ACGODs_KA @ 2024-10-18 20:23:03

不好意思,wssb,此贴结,打扰了


|