2016湖南省赛 A 2016 题解(同余)
题目链接
题目大意
给出正整数 n 和 m,统计满足以下条件的正整数对 (a, b) 的数量:
1<=a<=n 1<=b<=m a*b%2016=0
题目思路
我本来以为是容斥啥的,因为我写过一个类似的题目
然而这个2016因子太多,完全不知怎么写
其实很简单如果
\(i*j\;mod\;2016=0\)
\((i+k_1*2016)*(j+k_2*2016)\;mod\;2016=0\)
代码
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define fi first
#define se second
#define debug printf(" I am here\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
const double eps=1e-10;
int n,m;
signed main(){
while(scanf("%d%d",&n,&m)!=-1){
ll ans=0;
for(int i=1;i<=2016;i++){
for(int j=1;j<=2016;j++){
if(i*j%2016==0&&n>=i&&m>=j){
ans+=1ll*(1+(n-i)/2016)*(1+(m-j)/2016);
}
}
}
printf("%lld\n",ans);
}
return 0;
}
2016湖南省赛 A 2016 题解(同余)的更多相关文章
- 2016湖南省赛----A 2016 (同余定理)
2016湖南省赛----A 2016 (同余定理) Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 ...
- 2016湖南省赛 I Tree Intersection(线段树合并,树链剖分)
2016湖南省赛 I Tree Intersection(线段树合并,树链剖分) 传送门:https://ac.nowcoder.com/acm/contest/1112/I 题意: 给你一个n个结点 ...
- 2016湖南省赛----G - Parenthesis (括号匹配)
2016湖南省赛----G - Parenthesis (括号匹配) Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of lengt ...
- 2016湖南省赛--A题--2016
2016 [TOC] Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input ...
- 第十二届湖南省赛 A - 2016 ( 数学,同余转换)
给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 ...
- 2016湖南省赛 [Cloned]
A.2016 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m; 2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数 ...
- CSU 1803 2016 湖南省2016省赛
1803: 2016 Submit Page Summary Time Limit: 5 Sec Memory Limit: 128 Mb Submitted: 1416 ...
- 2016 湖南省省赛 Problem A: 2016
Problem A: 2016 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 296 Solved: 171 Description 给出正整数 n ...
- 2017 湖南省赛 K Football Training Camp
2017 湖南省赛 K Football Training Camp 题意: 在一次足球联合训练中一共有\(n\)支队伍相互进行了若干场比赛. 对于每场比赛,赢了的队伍得3分,输了的队伍不得分,如果为 ...
随机推荐
- Web前端_流式布局(百分比布局)
移动Web_流式布局(百分比布局) writer:late at night codepeasant 1(百分比布局) ☞核心知识点 1.流式布局(百分比布局) 2.视口设置 ☞今日目标 1. 能够使 ...
- VC获取文件后缀名
VC获取文件后缀名 2011-07-28 10:30:50| 分类: Visual C++ and O | 标签: |举报 |字号大中小 订阅 1. CString GetSuffix(C ...
- python开发基础(二)运算符以及数据类型之bool(布尔值))
# encoding: utf-8 # module builtins # from (built-in) # by generator 1.147 """ Built- ...
- 分布式文档存储数据库之MongoDB索引管理
前文我们聊到了MongoDB的简介.安装和对collection的CRUD操作,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/13941797.html:今天我 ...
- VS中Dev控件在工具箱里的不见的解决办法
出现问题:调整了VS中Dev控件后(以免生成程序每次都要在客户机上面注册dev),之前安装的DEV控件在vs工具箱中消失了,重装可以解决,但是太费时间了,检测dev自带的设置,找到了解决办法. 解决办 ...
- leetcode4:sort-list
题目描述 在O(n log n)的时间内使用常数级空间复杂度对链表进行排序. Sort a linked list in O(n log n) time using constant space co ...
- 搭建面向NET Framework的CI/CD持续集成环境(一)Windows服务器安装Jenkins
前言 网上大多数都是针对主流的Spring Cloud.NET Core的CI/CD方案.但是目前国内绝大部分的公司因为一些历史原因无法简单的把项目从NET Framework切换升级到NET Cor ...
- 使用bootstrap fileinput多文件拖拽上传的记录
今天琢磨文件上传,刚好看到bootstrap 我就搜了一下,刚刚能满足需求,使用上手也很快,使用完还是记录下来. 1.首先我们下载插件包,可以用nuget搜索bootstrap-fileinput 也 ...
- Spring Boot 2.4 正式发布,重大调整!!!
大家周末愉快啊,Spring Boot 2.3.5 没发布几天,你看,还是 1 周前发布的: 昨天又有粉丝留言说 Spring Boot 2.4.0 已经发布了: 我了个去,栈长赶紧跑到 Spring ...
- Vuex原理详解
一.Vuex是什么 Vuex是专门为Vuejs应用程序设计的状态管理工具.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生改变.它集中于MVC模式中的Model层 ...