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;
}
posted @ 2020-09-11 17:33  特立独行的猪猪  阅读(92)  评论(0编辑  收藏  举报