CF1342C Yet Another Counting Problem
Yet Another Counting Problem 思路:假设a <= b。 x % a % b = x % a是显然成立的,那么只需要比较 x % a != x % b % a的情况就可。 通过手写 x % a 和 x % b % a的情况,发现我们只需要写出一个lcm(a,b)的表格(lcm最小公倍数),就是一个循环表, 有了循环表,我们只需要统计一个循环表中每个位置不同余数的个数就可以,我们就可以处理1e18的数据了。 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <functional> 5 #include < set > 6 #include <vector> 7 #include <queue> 8 #include <cstring> 9 10 11 using namespace std; 12 13 #define ll long long 14 #define pb push_back 15 #define fi first 16 #define se second 17 18 const int N = 1010 ; 19 const int INF = 1e9; 20 21 int gcd( int a, int b){ 22 return b