湖南省第十二届大学生程序设计竞赛A题 2016 (csuoj1803)

Description

 给出正整数 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

HINT

Source

湖南省第十二届大学生计算机程序设计竞赛

这道题应该是省赛中最简单的题了,但是对弱新来说感觉其实还是很难找到正确的思路。

主要就是把n,m取余,然后做2016X2016的枚举

AC代码如下:

#include 

using namespace std;
typedef long long LL;
const int mod=2016;
int c[mod+5],d[mod+5];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        LL ans=0;
        int x=n%mod;
        int y=m%mod;
        int a=n/mod;
        int b=m/mod;
        c[0]=a,d[0]=b;
        for(int i=1;i

你可能感兴趣的:(csuoj)