按题意模拟,将 个数相加即可。
坑点
俗话说得好,十年 OI 一场空,不开 long long 见祖宗。
但是这样还不够, ,会爆 long long ,得用 unsigned long long 。
但这样还会被 hack ,数据如下:
hack数据
in:
1
4611686018427387904 4611686018427387904 4611686018427387904 4611686018427387904out:
0
ans:
18446744073709551616
此时如果是 C++ 选手就要特判了。
AC代码
#include <iostream>
using namespace std;
typedef unsigned long long ull;
const ull TWO62 = 4611686018427387904ULL;
int main() {
int t;
cin >> t;
while (t--) {
ull a, b, c, d;
cin >> a >> b >> c >> d;
if (a == TWO62 && b == TWO62 && c == TWO62 && d == TWO62) cout << "18446744073709551616\n";
else cout << a + b + c + d << endl;
}
return 0;
}