提交记录 19230


用户 题目 状态 得分 用时 内存 语言 代码长度
xj_liu20 1004. 【模板题】高精度乘法 Compile Error 0 0 ns 0 KB C++ 1.67 KB
提交时间 评测时间
2023-02-26 16:13:14 2023-02-26 16:13:15
#include <iostream>
#include <cstdio>
#include <string.h>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main()
{
    int i = 0;
    unsigned int SPa[5001];
    unsigned int SPb[5001];
    unsigned long long int Result[10003];
    string Sa;
    string Sb;
    stringstream ss;
        char tmp[4];
        Sa << cin;
        Sb << cin;
        int Length_a = (Sa.size()%4 != 0) ? Sa.size()/4 + 1 : Sa.size()/4;
        int Length_b = (Sb.size()%4 != 0) ? Sb.size()/4 + 1 : Sb.size()/4;
        for (int j = 0; j < Length_a+Length_b+1;j++)
        {
            Result[j] = 0;
        }

        for (int j = 0;j<Length_a-1;j++)
        {
            strcpy(tmp,Sa.substr(Sa.size()-(j+1)*4,4).c_str());
            SPa[j] = atoi(tmp);
        }
        strcpy(tmp,Sa.substr(0,Sa.size()-(Length_a-1)*4).c_str());
        SPa[Length_a-1] = atoi(tmp);

        for (int j = 0;j<Length_b-1;j++)
        {
            strcpy(tmp,Sb.substr(Sb.size()-(j+1)*4,4).c_str());
            SPb[j] = atoi(tmp);
        }
        strcpy(tmp,Sb.substr(0,Sb.size()-(Length_b-1)*4).c_str());
        SPb[Length_b-1] = atoi(tmp);

        for(int j = 0;j < Length_a;j++)
        {
            for(int k = 0;k < Length_b;k++)
            {
                Result[j+k] += SPa[j]*SPb[k];
            }
        }
        for(int j = 0; j < Length_a+Length_b;j++)
        {
            Result[j+1] += Result[j] / 10000;
            Result[j] = Result[j] % 10000;
        }
        ss.str("");
        for(int j = Length_a+Length_b; j >= 0;j--)
        {
            if(Result[j] != 0)
            {
                ss << Result[j];
            }
        }
        ss << endl;
    cout << ss.str();
    return 0;

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2025-09-15 21:13:23 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠