60 分求助

P1303 A*B Problem

MaxLHy @ 2024-10-07 09:39:49

后两个测试节点 WA, 望解答.

#include<iostream>
using u128=__uint128_t;
auto read()->u128{
    u128 x{},f{1};
    char ch{getchar()};
    while(ch<'0'||ch>'9'){
        if(ch=='-'){
            f=-1;
        }
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
auto write(u128 x)->void{
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9){
        write(x/10);
    }
    putchar(x%10+'0');
}
auto main()->int{
    u128 a{read()},b{read()};
    write(a*b);
    return 0;
}

by Miracle_1024 @ 2024-10-07 09:43:36

@MaxLHy

看数据范围,128输入太大还是会炸


by Oildum @ 2024-10-07 09:51:57


|