提交记录 18051


用户 题目 状态 得分 用时 内存 语言 代码长度
JOJO 1004a. 【模板题】高精度乘法2 Runtime Error 0 28.554 ms 168 KB C++ 995 B
提交时间 评测时间
2022-09-19 21:57:35 2022-09-19 21:57:37
#include <iostream>
using namespace std;

const int scale = 10;

int main() {
    string aa, bb;
    int a[5001], b[5001], c[5001], nc[10004];
        cin >> aa >> bb;
        if (aa=="0" || bb=="0") {
            cout << 0;
            return 0;
        }
        int sizea = aa.length();
        int sizeb = bb.length();
        for (int i = 0; i < sizea; i++) {
            a[i] = aa[sizea - i - 1] - '0';

        }
        for (int i = 0; i < sizeb; i++) {
            b[i] = bb[sizeb - i - 1] - '0';

        }
        int sizec = sizea + sizeb - 1;

        for(int i=0;i<sizea;i++){
for(int j=0;j<sizeb;j++){
c[i+j]+=a[i]*b[j];
}
}
        nc[0] = c[0] % scale;
        for (int i = 1; i < sizec; i++) {
            c[i] += c[i - 1] / scale;
            nc[i] = c[i] % scale;
        }
        nc[sizec] = c[sizec - 1] / scale;
        if (nc[sizec])
            cout << nc[sizec];
        for (int i = sizec - 1; i >= 0; i--) {
            cout << nc[i];
        }

    
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #128.554 ms168 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2022-10-05 06:22:23 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用