0
点赞
收藏
分享

微信扫一扫

CSUOJ—1803

小磊z 2022-09-07 阅读 57


A - 2016

 


  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:









1. 1≤a≤n,1≤b≤m;






2. a×b 是 2016 的倍数。



Input





输入包含不超过 30 组数据。






每组数据包含两个整数 n,m (1≤n,m≤10 9).



Output 对于每组数据,输出一个整数表示满足条件的数量。 Sample Input

32 63
2016 2016
1000000000 1000000000

Sample Output

1
30576
7523146895502644

【分析】 a*b%2016=0,预处理一下a,b中分别有多少个1的倍数,2的倍数,3的倍数... 然后枚举一下2016*2016就可以了...... 【代码】

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
long long a[3000];
long long b[3000];
int main()
{
long long n,m;
while(~scanf("%lld%lld",&n,&m))
{
for(int i=0;i<2016;i++) a[i]=n/2016,b[i]=m/2016;
for(int i=1;i<=n%2016;i++) a[i]++;
for(int i=1;i<=m%2016;i++) b[i]++;
long long ans=0;
for(int i=0;i<2016;i++)
for(int j=0;j<2016;j++)
if(i*j%2016==0)
ans+=a[i]*b[j];
printf("%lld\n",ans);
}
return 0;
}



举报

相关推荐

0 条评论