用 max 函数的时候发生一些神奇的事,比如这两段代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v;
unsigned long a, b;
max(v.size(), a + b);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long x[1000005];
int main()
{
max(lower_bound(x + 1, x + 10, 1) - x, 0L);
return 0;
}
能够在洛谷(Linux 系统)过编译,但必须把 A 处的 unsigned long 改为 unsigned long long、把 B 处的 0L 改为 0LL 才能在本地(Windows 系统)过编译。
请问这是什么原因,以及如何在考场避免这类问题(不用 Linux 系统)。