Description
给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:
1. 1≤a≤n,1≤b≤m;
2. a×b 是 2016 的倍数。
Input
输入包含不超过 30 组数据。
9).
Output
对于每组数据,输出一个整数表示满足条件的数量。
Sample Input
32 63
2016 2016
1000000000 1000000000
Sample Output
1
30576
7523146895502644
只要按照对2016取余分类在2016*2016枚举就可以了。
#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<bitset>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define loop(i,j,k) for (int i = j;i != -1; i = k[i])
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
#define ff first
#define ss second
#define mp(i,j) make_pair(i,j)
#define pb push_back
#define pii pair<int,LL>
#define in(x) scanf("%d", &x);
using namespace std;
typedef long long LL;
const int low(int x) { return x&-x; }
const double eps = 1e-4;
const int INF = 0x7FFFFFFF;
const int mod = 9973;
const int N = 1e5 + 10;
int n, m, f[N], g[N];
int main()
{
while (scanf("%d%d", &n, &m) != EOF)
{
rep(i, 1, 2016)
{
f[i] = n / 2016 + (n % 2016 >= i);
g[i] = m / 2016 + (m % 2016 >= i);
}
LL ans = 0;
rep(i, 1, 2016) rep(j, 1, 2016)
{
if (i*j % 2016) continue;
ans += 1LL * f[i] * g[j];
}
printf("%lld\n", ans);
}
return 0;
}