提交记录 8668


用户 题目 状态 得分 用时 内存 语言 代码长度
AThousandMoon 1004a. 【模板题】高精度乘法2 Accepted 100 250.067 ms 208 KB C++ 781 B
提交时间 评测时间
2019-03-03 09:02:10 2020-08-01 01:22:55
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 10003;
char str1[N], str2[N];
int n, m, a[N], b[N], c[N << 1];
int main(){
        scanf("%s%s", str1, str2);
        n = strlen(str1); m = strlen(str2);
        for(int i = 0;i < n;i ++) a[i] = str1[n - 1 - i] - '0';
        for(int i = 0;i < m;i ++) b[i] = str2[m - 1 - i] - '0';
        for(int i = 0;i < n;i ++){
                int x = 0;
                for(int j = 0;j < m;j ++){
                        c[i + j] += a[i] * b[j] + x;
                        x = c[i + j] / 10;
                        c[i + j] %= 10;
                }
                c[i + m] += x;
        }
        if(c[n + m - 1]) printf("%d", c[n + m - 1]);
        for(int i = n + m - 2;~i;i --)
                printf("%d", c[i]);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1250.067 ms208 KBAcceptedScore: 100


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