本地输出正确,但洛谷全WR求助

P1303 A*B Problem

KOTSRwy2 @ 2024-12-11 20:28:37

#include <bits/stdc++.h>
using namespace std;
void string_to_num(string & a,vector<int> & n)
{
    for(int i = 0;i < a.length();i++)
    {
        n[i] = a[a.length()-i-1] - '0';
    }
}

int main()
{
    string n1,n2;
    getline(cin,n1);
    getline(cin,n2);
    vector<int> num1(2001,0),num2(2001,0);
    vector<int> re(4e6+10,0);
    string_to_num(n1,num1);
    string_to_num(n2,num2);
    for(int i = 0;i < n1.length();i++)
        for(int j = 0;j < n2.length();j++)
            re[i + j] += num1[i] * num2[j];
    for(int i = 0;i < 4e6 + 10;i++)
    {
        if ( re[i] > 9 )
        {
            re[i + 1] += re[i] / 10;
            re[i] = re[i] % 10;
        }
    }
    bool flag = false;
    for(int i = 4e6+5;i >=1 ;i--)
    {
        if(re[i] != 0)
        {flag = true;}
        if(flag)
        {cout << re[i];}
    }
    cout << re[0];
    return 0;
}

by KOTSRwy2 @ 2024-12-11 21:31:00

@Terrible犯蠢了,噢过了,感谢大佬(≧∀≦)ゞ


by lipeizheng @ 2024-12-12 20:55:16

@KOTSRwy2DVE 会


by KOTSRwy2 @ 2024-12-12 21:49:31

@Terrible 谢谢大佬,过了q(≧▽≦q)~


上一页 |