当前位置: 首页> 房产> 市场 > 纬天建筑工程信息资讯网_镇江制作网页图片_免费加精准客源_手机百度搜索引擎入口

纬天建筑工程信息资讯网_镇江制作网页图片_免费加精准客源_手机百度搜索引擎入口

时间:2025/7/14 0:35:15来源:https://blog.csdn.net/weixin_74754298/article/details/143350125 浏览次数:0次
纬天建筑工程信息资讯网_镇江制作网页图片_免费加精准客源_手机百度搜索引擎入口

题目链接

Educational Codeforces Round 88 E. Modular Stability

思路

对于任意的非负整数 x x x,我们要满足 x % a % b = x % b % a x \% a \% b = x \% b \% a x%a%b=x%b%a。因为 a < b a < b a<b,所以只有 b b b a a a的倍数时才满足条件。

因此,我们可以枚举最小的 a a a,求出值域范围内有多少个它的倍数,然后使用组合数学计算答案即可。

代码

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int N = 5e5 + 5, M = 1e6 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f3f3f3f3f;
int n, k;
int fac[N], infac[N];
int qmi(int a, int b, int c)
{int res = 1;while (b){if (b & 1)res = res * a % c;b >>= 1;a = a * a % c;}return res;
}
void init()
{fac[0] = infac[0] = 1;for (int i = 1; i <= n; i++){fac[i] = fac[i - 1] * i % mod;infac[i] = infac[i - 1] * qmi(i, mod - 2, mod) % mod;}
}
int C(int a, int b)
{return fac[a] * infac[b] % mod * infac[a - b] % mod;
}
int MOD(int x)
{return (x % mod + mod) % mod;
}
void solve()
{cin >> n >> k;init();if (n < k){cout << 0 << endl;}else{int ans = 0;for (int i = 1; i <= n - k + 1; i++) //假设最小的a[i]为i{int num = n / i - 1;if (num < k - 1) break;ans = (ans + C(num, k - 1)) % mod;}cout << MOD(ans) << endl;}
}signed main()
{ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int test = 1;// cin >> test;for (int i = 1; i <= test; i++){solve();}return 0;
}
关键字:纬天建筑工程信息资讯网_镇江制作网页图片_免费加精准客源_手机百度搜索引擎入口

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: