# 如果是OI比赛中,且可以使用__int128
查看原帖
# 如果是OI比赛中,且可以使用__int128
130066
imTars楼主2022/2/24 17:26

如果是OI比赛中,且可以使用__int128,实际测试本题可以过掉前4个点,得到80分。如果忘了高精怎么写,可以骗骗分。

#include <cstdio>
#include <cctype>

__int128 read()
{
    __int128 x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') {
            f = -1;
        }
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return f * x;
}

void print(__int128 x)
{
    if (x != 0) {
        if (x < 0) {
            putchar('-');
            x = -x;
        }
        print(x / 10);
        putchar('0' + x % 10);
    }
}

int main()
{
    __int128 a = read(), b = read(), c = a + b;
    if (c) {
        print(c);
    } else {
        putchar('0');
    }
    puts("");
    return 0;
}

2022/2/24 17:26
加载中...