acm一些奇怪的知识

1.奇怪的越界问题

a*b%mod 依然可能会越界

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
int main()
{
	int a = 1e6,b = 1e6;
	int ans = a * b % mod;
	int ans2 = 1LL * a * b % mod;
	cout << ans << endl;   // -727379968
	cout << ans2 << endl;  // 999993007
	return 0;
}
原文地址:https://www.cnblogs.com/xiaoxiao179/p/13652942.html