如果 a * b % 2016 == 0
如果a = 1 ,且 a * b % 2016 == 0
考虑一下a = 2017的时候
2017 * b = (2016 + 1) * b % 2016 == 0必定成立
那么就是说1中搭配成的b,2017一样能搭配。
同样:4033 * b = (2016 + 2016 + 1) * b % 2016 == 0必定成立
所以,我可以枚举[1,2016]中[1,2016]中,i * j % 2016 == 0的对数,然后乘上对应的[1,n]中有i这个数的个数,代替数也算,代替数就是那些等价数,1 --- 2017 --- 4033
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
LL n, m;
const int maxn = + ;
LL numn[maxn], numm[maxn];
void work () {
LL tnk = n / ;
LL rn = n % ;
memset (numn, , sizeof numn);
memset (numm, , sizeof numm);
for (int i = ; i <= rn; ++i) {
numn[i] = tnk + ;
}
for (int i = rn + ; i <= ; ++i) {
numn[i] = tnk;
}
LL tmk = m / ;
LL rm = m % ;
for (int i = ; i <= rm; ++i) {
numm[i] = tmk + ;
}
for (int i = rm + ; i <= ; ++i) {
numm[i] = tmk;
}
LL ans = ;
for (int i = ; i <= ; ++i) {
for (int j = ; j <= ; ++j) {
if ((i * j) % == ) {
ans += numn[i] * numm[j];
}
}
}
cout << ans << endl;
}
int main () {
#ifdef local
freopen("data.txt","r",stdin);
#endif
while (cin >> n >> m) {
work ();
}
return ;
}