为啥全RE了?

P1303 A*B Problem

Liuzhenyuan @ 2023-07-17 19:06:40


#include<bits/stdc++.h>
using namespace std;
vector<int> mul(vector<int> A,vector<int> B)
{
    vector<int> c;
    int t=0;
    for(int i=B.size()-1;i>=0;i--)
    {
        for(int j=0;j<A.size();j++)
        {
            t+=A[j]*B[i];
            c.push_back(t%10);
            t/=10;
        }
    }
    return c;
}
int main()
{
    string a,b;
    cin>>a>>b;
    vector<int> A,B;
    for(int i=a.size()-1;i>=0;i--)
    {
        A.push_back(a[i]-48);
    }
    for(int i=b.size()-1;i>=0;i--)
    {
        B.push_back(b[i]-48);
    }
    vector<int> c=mul(A,B);
    for(int i=c.size()-1;i>=0;i--)
    {
        cout<<c[i];
    }
    return 0;
}

by FengYuXinMing @ 2023-07-17 19:16:48

@Liuzhenyuan 越界?


by Adorable_ @ 2023-07-17 19:33:37

@ababbjxzt 动态越界?


by FengYuXinMing @ 2023-07-17 19:46:11

@Adorable_ 这么说也对,vector是动态的,按道理来说不会越界啊,可是一般RE越界占多数,所以我也不太明白,没准您学的多,一看没准改好了


by Adorable_ @ 2023-07-17 19:47:56

@ababbjxzt 别别别,我是个蒟蒻(),dalao都不会得题,我也不会(缩成一团)


by FengYuXinMing @ 2023-07-17 19:53:01

@Adorable_ 我也是蒟蒻,您能熟练运用vector,我才刚学,还是个fw(蜷缩在角落)


by Adorable_ @ 2023-07-17 19:55:58

@ababbjxzt 我也刚学dp()


by Adorable_ @ 2023-07-17 19:56:46

@ababbjxzt 户关户关,


by FengYuXinMing @ 2023-07-17 20:04:31

@Adorable_ 啊?dp?dp我都没学啊?您是学dp才学的vector?我是贪心学的


by FengYuXinMing @ 2023-07-17 20:04:46

@Adorable_ ok


by FengYuXinMing @ 2023-07-17 20:05:25

@Adorable_ 突然发现,你不是楼主···


| 下一页