提交记录 3192


用户 题目 状态 得分 用时 内存 语言 代码长度
hannibal 1004a. 【模板题】高精度乘法2 Accepted 100 57.921 ms 212 KB C++11 880 B
提交时间 评测时间
2018-07-10 14:26:57 2020-07-31 21:12:25
#include<stdio.h>
#include<string.h>
 char numberN[10005], numberM[10005];
int main() {
    scanf("%s%s", numberN, numberM);
    int n = strlen(numberN), m = strlen(numberM);
    int a[n], b[m];
    int i, j;
    for (i = 0, j = n - 1; i < n; i++, j--) {
        a[i] = numberN[j] - '0';
    }
    for (i = 0, j = m - 1; i < m; i++, j--) {
        b[i] = numberM[j] - '0';
    }
    int c[21000];
    for (i = 0; i < 21000; i++) {
        c[i] = 0;
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            c[i + j] += a[i] * b[j];
        }
    }
    for (i = 0; i < n + m; i++) {
        if (c[i] >= 10) {
            c[i + 1] += c[i] / 10;
            c[i] %= 10;
        }
    }
    for (j = 20999; j > 0; j--) {
        if (c[j] != 0)
        break;
    }
    for (i = j; i >= 0; i--) {
    printf("%d", c[i]);
    }
    printf("\n");
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #157.921 ms212 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:16:27 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠