题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803

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

  1. 32 63
  2. 2016 2016
  3. 1000000000 1000000000

Sample Output

  1. 1
  2. 30576
  3. 7523146895502644
 
题解:
根据 (a * b) mod 2016 = [(a mod 2016) * (b mod 2016)] % 2016,
我们可以求出amo[1~2016][1~2016](也就是说当n≤2016且m≤2016时的问题答案);
然后对于n>2016或者m>2016的情况,那么就把 n 变成 k1*2016+g1,m 变成 k2*2016+g2 的形式;
那么他们互相组合就可以得到 amo[2016][2016]*k1*k2 + amo[g1][2016]*k2 + k1*amo[2016][g2] + amo[g1][g2].
 
AC代码:
  1. #include<cstdio>
  2. using namespace std;
  3. typedef long long LL;
  4.  
  5. LL n,m;
  6. LL amo[][];
  7. void init()
  8. {
  9. LL sum;
  10. amo[][]=;
  11. for(int i=;i<=;i++)
  12. {
  13. amo[i][]=amo[][i]=;
  14. sum=;
  15. for(int j=;j<=;j++)
  16. {
  17. if((i*j)%==) sum++;
  18. amo[i][j]=amo[i-][j]+sum;
  19. }
  20. }
  21. }
  22.  
  23. int main()
  24. {
  25. init();
  26. while(scanf("%lld%lld",&n,&m)!=EOF)
  27. {
  28. LL a1=n/, b1=n%;
  29. LL a2=m/, b2=m%;
  30. printf("%lld\n",amo[][]*a1*a2+a1*amo[][b2]+a2*amo[b1][]+amo[b1][b2]);
  31. }
  32. }

注意:CSU的OJ不能使用bits/stdc++.h,同时注意数字范围超int,需要使用long long.

CSU 1803 - 2016 - [同余]的更多相关文章

  1. CSU 1803 2016(数论)

    2016 Problem Description: 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1≤a≤n,1≤b≤m; a×b 是 2016 的倍数. Input: 输 ...

  2. CSU 1803 2016 湖南省2016省赛

    1803: 2016 Submit Page   Summary   Time Limit: 5 Sec     Memory Limit: 128 Mb     Submitted: 1416    ...

  3. 【模拟】【数学】CSU 1803 2016 (2016湖南省第十二届大学生计算机程序设计竞赛)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 题目大意: 给定n,m(n,m<=109)1<=i<=n,1& ...

  4. CSU 1803 2016

    湖南省第十二届大学生计算机程序设计竞赛$A$题 枚举. 处理一下$\% 2016$之后的数分别有几个,然后$2016*2016$枚举一下统计方案数就可以了. #pragma comment(linke ...

  5. CSU - 1803 —— 数学题

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Description  给出正整数 n 和 m,统计满足以下条件的正整数对 ...

  6. 十二届 - CSU 1803 :2016(同余定理)

    题目地址:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Knowledge Point: 同余定理:两个整数a.b,若它们除以整数m所 ...

  7. csu 1803(余数分类)

    1803: 2016 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 565  Solved: 364[Submit][Status][Web Board ...

  8. 【CSU 1803】2016

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 Solution: 考虑两个数x,y乘积%2016=0 x×y≡0(MOD 2016) x= ...

  9. 【CSU 1803】2016 (数学)

    Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 ...

随机推荐

  1. c#系统消息类封装

    今天封装了一个返回json的消息类 using System; using System.Collections.Generic; using System.Linq; using System.Te ...

  2. it码农之心灵鸡汤(一)

    到底该怎么面对工作,到底怎么面临人生.到底怎么面临青春,对于打工的人来说这些一直都是心中一直无法解惑的谜团. 对于人们怎样看待工作,以前华为创始人任正非说过:非常多人问我,来公司工作有没有双休?需不须 ...

  3. Java实现窗体动态加载磁盘文件

    在使用图形界面操作系统时,当打开一个文件夹系统会自动列出该文件夹下的所有文件及子文件夹.本实例实现了类似的功能:首先让用户选择一个文件夹,程序会动态列出该文件夹下的所有文件:如果该文件是隐藏文件,就在 ...

  4. nyoj 1239 引水project (河南省第八届acm程序设计大赛)

    题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...

  5. java.lang.Class<T> -- 反射机制及动态代理

    Interface : Person package java_.lang_.component.bean; public interface Person { String area = " ...

  6. Eclipse cdt解决github导入的项目无法打开声明的bug (cannot open declaration)

    概述: 我利用eclipse 的git插件clone github上的远程项目(C++)到本地时遇到一个问题:clone下来的项目没有C++特性,无法使用open declaration等操作,下面是 ...

  7. Python中的类(中)

    上一篇介绍了Python中类相关的一些基本点,本文看看Python中类的继承和__slots__属性. 继承 在Python中,同时支持单继承与多继承,一般语法如下: class SubClassNa ...

  8. HTML 换行

    <br /> 标签可以用于换行 <!DOCTYPE HTML> <html> <body> <p> I like Playing. < ...

  9. [PyCharm] 设置自动启动时自动打开项目

    设置启动PyCharm时自动打开(或不打开)上次进行的项目: 选择 “Settings - General - Reopen last project on startup”,勾选该选项则启动时自动打 ...

  10. [Python] Unofficial Windows Binaries for Python Extension Packages

    1. Unofficial Windows Binaries for Python Extension Packages 非官方的Python第三方库,提供基于Windows的二进制扩展包,由加州大学 ...