2016-CSU1803(同余公式)
来源:互联网 发布:调用接口获取json数据 编辑:程序博客网 时间:2024/04/26 19:30
题目链接
题意:求满足a * b 是 2016的倍数的对数, 1<= a <=n, 1<= b <=m;
思路:定义一个数组,算出0-n对2016取余,数组中第i个数表示0-n之间对2016取余为i的个数。同理,对0-m也开一个数组处理。
最后只需要算出两个数组的每个数相乘的和。
代码:
/// He renders landscapes with great skill and artistry. #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cstdlib> #include <cmath> #include <iterator> #include <cctype> #include <sstream> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include <deque> #include <queue> #include <list> #include <functional> #include <ctime> #include <bitset> //#pragma comment(linker, "/STACK:102400000, 102400000") #define debug puts("+******************************************************+") #define Min(a, b) ( (a < b) ? a : b ) #define Max(a, b) ( (a > b) ? a : b ) #define lc o<<1 #define rc o<<1|1 #define lson L, M, lc #define rson M + 1, R, rc #define mem0(x) memset(x, 0, sizeof x) #define mem1(x) memset(x, -1, sizeof x) #define memf(x) memset(x, false, sizeof x) #define pb push_back #define pf push_front #define LB lower_bound #define UB upper_bound #define PQ priority_queue #define fr(x) freopen("x", "r", stdin ) #define fw(x) freopen("x", "w" , stdout) #define all(a) a.begin(), a,end() #define X first #define Y second #define MP make_pair #define Abs(x) ( x >= 0 ) ? x : ( -x ) #define MAXS 50000 + 8 #define MAXT 10000 + 8 #define MAXL 500000 + 8 #define INF 0x3f3f3f3f #define INFL 1000000000000000000 #define inf -(1<<30) #define EPS 1e-10 #define PI acos(-1.0) #define sqr(x) (x * x) using namespace std; typedef long long LL; typedef unsigned long long uLL; typedef double DB; typedef long double LD; typedef pair<int, int > pii; typedef pair<LL, LL> pll; const int MOD = 1e9; const int N = 1e5 + 8; const int maxn = 1e3 + 8; const int dx[] = { -1, 1, 0, 0 }; const int dy[] = { 0, 0, -1, 1 }; struct Node { LL x; int id; char ch; bool operator < ( const Node & n) const { return x < n.x; } } no[N]; int t; LL n, m; LL a[2020], b[2020]; int main() { //freopen("codecoder.in", "r", stdin); //freopen("out.txt", "w", stdout); // ios::sync_with_stdio(false); while (~scanf("%lld%lld", &n, &m)) { LL ans = 0; mem0(a); mem0(b); for (int i = 0; i < 2016; i++) { a[i] = n / 2016; b[i] = m / 2016; } for (int i = 1; i <= n % 2016; i++) a[i]++; for (int i = 1; i <= m % 2016; i++) b[i]++; for (int i = 0; i < 2016; i++) { for (int j = 0 ; j < 2016; j++) { if ( i * j % 2016 == 0 ) ans += (LL)a[i] * b[j]; } } printf("%lld\n", ans); } return 0; }
0 0
- 2016-CSU1803(同余公式)
- CSU1803 2016(同余)
- CSU1803 2016 同余
- 同余公式和性质
- poj 1845 Sumdiv(同余模公式)
- 2016 (同余定理)
- 关于同余的公式性质总结
- csu1803——2016(数学)
- 模运算与同余公式的性质
- 模运算与同余公式的性质
- 同余问题(3)一元线性同余方程组
- POJ 3844(同余)
- 数论(同余+hash)
- Light1078(同余定理)
- 同余方程(扩欧)
- CSU 1803 2016(16湖南省赛)(同余定理)
- 2016湖南省省赛A-2016(CSU1803)
- 同余
- manifest中的largeHeap是干什么用的?
- 救基友2
- ThinkPHP结构
- 7种结构型模式之:代理模式 、JDK动态代理、cglib动态代理
- Maven配置文件中修改默认jre
- 2016-CSU1803(同余公式)
- Learn web development css初步
- Servlet监听器——实现在线登录人数统计小例子
- android颜色对应的xml配置值,颜色表
- unix系统之getpid()
- 【POJ】1741 Tree
- java中 set,list,array互转
- C#基础语言
- 苹果笔记本开机出现闪烁的问号文件夹解决方法