码迷,mamicode.com
首页 > 其他好文 > 详细

2016

时间:2016-09-14 20:27:08      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

 给出正整数 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=k*2016+s,b=kk*2016+h;
那么a*b=。。。。+sh,前面的能被2016整除的部分,那么只要s*h能被2016整除,s<2016,h<2016,那么枚举s,h即可。
 1 #include<stdio.h>
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<string.h>
 5 #include<queue>
 6 #include<stack>
 7 #include<map>
 8 #include<math.h>
 9 #include<set>
10 using namespace std;
11 typedef long long LL;
12 int main(void)
13 {
14         LL n,m;
15         while(scanf("%lld %lld",&n,&m)!=EOF)
16         {       LL sum = 0;
17                 for(int i = 1; i <= min((LL)2016,n); i++)
18                 {
19                         for(int j = 1; j <= min((LL)2016,m); j++)
20                         {
21                                 if((i*j)%2016==0)
22                                 {
23                                    LL x = (n-i)/2016+1;
24                                    LL y = (m-j)/2016+1;
25                                    sum += x*y;
26                                 }
27                         }
28                 }
29                 printf("%lld\n",sum);
30         }
31         return 0;
32 }

 



2016

标签:

原文地址:http://www.cnblogs.com/zzuli2sjy/p/5873269.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!