文章

6

粉丝

0

获赞

3

访问

347

头像
大整数乘法 题解:
P1475
发布于2026年2月13日 16:10
阅读数 27

一开始用的char ans数组,通过率只有83,惊奇的发现acsii码值最大到127,所以一定要用int数组!

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int len;
    cin>>len;
    string  a,b;
    cin>>a>>b;
    int ans[205];                               //这里!不能char ans;
    memset(ans,0,sizeof(ans));
    int i,j,w=0,h,k;
    for(i=len-1; i>=0; i--)
    {
        h=0;
        for(j=len-1; j>=0; j--)
        {
            k=w+h;

            ans[k]+=(b[i]-'0')*(a[j]-'0');
            //cout<<ans[k]-'0'<<endl;
            while(ans[k]>9)
           ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发