湖南省第十二届大学生计算机程序设计竞赛 problem A 2016
2016-09-03 23:31
417 查看
如果 a * b % 2016 == 0
如果a = 1 ,且 a * b % 2016 == 0
考虑一下a = 2017的时候
2017 * b = (2016 + 1) * b % 2016 == 0必定成立
那么就是说1中搭配成的b,2017一样能搭配。
同样:4033 * b = (2016 + 2016 + 1) * b % 2016 == 0必定成立
所以,我可以枚举[1,2016]中[1,2016]中,i * j % 2016 == 0的对数,然后乘上对应的[1,n]中有i这个数的个数,代替数也算,代替数就是那些等价数,1 --- 2017 --- 4033
View Code
如果a = 1 ,且 a * b % 2016 == 0
考虑一下a = 2017的时候
2017 * b = (2016 + 1) * b % 2016 == 0必定成立
那么就是说1中搭配成的b,2017一样能搭配。
同样:4033 * b = (2016 + 2016 + 1) * b % 2016 == 0必定成立
所以,我可以枚举[1,2016]中[1,2016]中,i * j % 2016 == 0的对数,然后乘上对应的[1,n]中有i这个数的个数,代替数也算,代替数就是那些等价数,1 --- 2017 --- 4033
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> using namespace std; #define inf (0x3f3f3f3f) typedef long long int LL; #include <iostream> #include <sstream> #include <vector> #include <set> #include <map> #include <queue> #include <string> LL n, m; const int maxn = 2016 + 20; LL numn[maxn], numm[maxn]; void work () { LL tnk = n / 2016; LL rn = n % 2016; memset (numn, 0, sizeof numn); memset (numm, 0, sizeof numm); for (int i = 1; i <= rn; ++i) { numn[i] = tnk + 1; } for (int i = rn + 1; i <= 2016; ++i) { numn[i] = tnk; } LL tmk = m / 2016; LL rm = m % 2016; for (int i = 1; i <= rm; ++i) { numm[i] = tmk + 1; } for (int i = rm + 1; i <= 2016; ++i) { numm[i] = tmk; } LL ans = 0; for (int i = 1; i <= 2016; ++i) { for (int j = 1; j <= 2016; ++j) { if ((i * j) % 2016 == 0) { ans += numn[i] * numm[j]; } } } cout << ans << endl; } int main () { #ifdef local freopen("data.txt","r",stdin); #endif while (cin >> n >> m) { work (); } return 0; }
View Code
相关文章推荐
- CSU Problem 1803 2016(同余定理)——湖南省第十二届大学生计算机程序设计竞赛
- csu 2016年湖南省第十二届大学生计算机程序设计竞赛Problem A 2016
- 2016年湖南省第十二届大学生计算机程序设计竞赛:A—2016
- 湖南省第十二届大学生计算机程序设计竞赛 A 2016
- 【贪心】CSU 1809 Parenthesis (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【最短路】【STL】CSU 1808 地铁 (2016湖南省第十二届大学生计算机程序设计竞赛)
- 湖南省第十二届大学生计算机程序设计竞赛 2016
- CSU Problem 1809 Parenthesis(括号匹配,线段树,前缀和)——湖南省第十二届大学生计算机程序设计竞赛
- CSU 1803 2016【湖南省第十二届大学生计算机程序设计竞赛 A题】
- 【最短路】【STL】CSU 1808 地铁 (2016湖南省第十二届大学生计算机程序设计竞赛)
- 湖南省第十二届大学生计算机程序设计竞赛 A 2016
- 【拓扑】【宽搜】CSU 1084 有向无环图 (2016湖南省第十二届大学生计算机程序设计竞赛)
- CSU 1803 2016 (数学)【2016年湖南省第十二届大学生计算机程序设计竞赛 - A】
- 【数学】CSU 1810 Reverse (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【数学】CSU 1810 Reverse (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【树状数组】CSU 1811 Tree Intersection (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【模拟】CSU 1807 最长上升子序列~ (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【树状数组】CSU 1811 Tree Intersection (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【模拟】CSU 1807 最长上升子序列~ (2016湖南省第十二届大学生计算机程序设计竞赛)
- 【最短路】【数学】CSU 1806 Toll (2016湖南省第十二届大学生计算机程序设计竞赛)