[Solution] nloj.0002-題解

題解

這題考你對資料型別的熟悉度,正常 int 的大小為 $[-2$${31}$ $, \ 2$${31}$ $- 1]$
那 $a$ 和 $b$ 最大都是 $2$${31}$ $- 1$ $\implies$ $a + b$ 最大會是 $2$${32}$ $- 2$
很明顯超出了 int 型別的上限

所以這題 $a$ 和 $b$ 都要是 long long

程式碼

#include <iostream>
using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;

    cout << a + b;

    return 0;
}
View Post