CSU - 1803 —— 数学题
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803
Description
Input
Output
Sample Input
32 63
2016 2016
1000000000 1000000000
Sample Output
1
30576
7523146895502644
题解:
x,y分别对2016取余,如果x*y 是2016的倍数的话,那么(2016*k + x)*y也是2016的倍数。
所以只需要统计这n个数之内,对2016取余后的数所出现的次数就可以了。
分两部分统计:
1.对于1~2016*k(k>=1)的数来说,2016的每个余数都已经出现了k遍,所以每个余数的出现次数都+k;
2.对于余下不足凑成2016个数的数来说,只需要把他们%2016的余数所出现的次数+1就可以了;
最后再对两个集合进行枚举相乘,看看是否为2016的倍数就可以了。
做过类似的题:http://blog.csdn.net/dolfamingo/article/details/62890375
代码如下:
#include<iostream>//CSU 1803 2016
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define LL long long using namespace std; int a[2020], b[2020]; int main()
{
int n, m,rn,rm;
while(scanf("%d%d",&n,&m)!=EOF)
{
rn = n/2016;
rm = m/2016; for(int i = 0; i<2016; i++)//看2016出现了多少次, 每一次2016当中所有余数都会出现一遍
{
a[i] = rn;
b[i] = rm;
} rn = n%2016;
rm = m%2016;
for(int i = 1; i<=rn; i++) a[i]++;
for(int i = 1; i<=rm; i++) b[i]++; LL ans = 0;
for(int i = 0; i<2016; i++)
for(int j = 0; j<2016; j++)
{
if((i*j)%2016==0)
ans += (LL)a[i]*(LL)b[j];
} printf("%lld\n",ans);
}
}
CSU - 1803 —— 数学题的更多相关文章
- CSU 1803 2016(数论)
2016 Problem Description: 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1≤a≤n,1≤b≤m; a×b 是 2016 的倍数. Input: 输 ...
- 【模拟】【数学】CSU 1803 2016 (2016湖南省第十二届大学生计算机程序设计竞赛)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 题目大意: 给定n,m(n,m<=109)1<=i<=n,1& ...
- CSU 1803 - 2016 - [同余]
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. ...
- 【CSU 1803】2016
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803 Solution: 考虑两个数x,y乘积%2016=0 x×y≡0(MOD 2016) x= ...
- 十二届 - CSU 1803 :2016(同余定理)
题目地址:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1803 Knowledge Point: 同余定理:两个整数a.b,若它们除以整数m所 ...
- csu 1803(余数分类)
1803: 2016 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 565 Solved: 364[Submit][Status][Web Board ...
- CSU 1803 2016 湖南省2016省赛
1803: 2016 Submit Page Summary Time Limit: 5 Sec Memory Limit: 128 Mb Submitted: 1416 ...
- CSU 1803 2016
湖南省第十二届大学生计算机程序设计竞赛$A$题 枚举. 处理一下$\% 2016$之后的数分别有几个,然后$2016*2016$枚举一下统计方案数就可以了. #pragma comment(linke ...
- 【CSU 1803】2016 (数学)
Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 ...
随机推荐
- Linux终端颜色设置
http://blog.sina.com.cn/s/blog_65a8ab5d0101g6cf.html http://www.tuicool.com/articles/NRZfIj #PS1='${ ...
- 邁向IT專家成功之路的三十則鐵律 鐵律十:IT人思維之道-跳脫框架
莊子的哲學思想歸本於老子,他認為人要解脫束縛必須做到不從任何的角度與任何的時間來看待事物,而是必須與天地同體,然而也唯有如此才能看清宇宙間萬事萬理的真諦.無論是莊子還是老子,他們畢竟是中國古代的聖賢, ...
- tensorflow提示出错'module' object has no attribute 'pack'
编译旧的代码,会像下面这样提示出错: deconv_shape3 = tf.pack([shape[0], shape[1], shape[2], NUM_OF_CLASSESS]) Attribut ...
- cocos2d-x3.0 PageView
.h加入例如以下代码: void pageViewEvent(Ref *pSender, PageViewEventType type); .m layout = Layout::create(); ...
- SilverLight:基础控件使用(3)-DataGrid控件
ylbtech-SilverLight-Basic-Control:基础控件使用(3)-DataGrid控件 DataGrid控件-后台绑定 自动生成表列 不自动生成表列 1.A,返回顶部Person ...
- DICOM:DICOM Print 服务详细介绍
目录(?)[-] 背景 DICOM Print服务数据流 DICOM Print服务各部分关系 DICOM Print服务具体实现 背景: 昨天专栏中发表了一篇关于DICOM Print的博文 ...
- Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?
I see pretty much all the answers recommend deleting the lock. I don't recommend doing that as a fir ...
- react request.js 函数封装
1.request.js 函数封装 import { Toast } from 'antd-mobile'; import axios from 'axios'; import store from ...
- Android自己定义View的实现方法
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17357967 不知不觉中,带你一步步深入了解View系列的文章已经写到第四篇了.回 ...
- C# 将cookie写入WebBrowser
string cookie = ""; foreach (string c in cookie.Split(';')) { string[] item = c.Split('=') ...