QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#776122 | #9553. The Hermit | Chihiro | WA | 10ms | 8396kb | C++17 | 1.5kb | 2024-11-23 17:38:00 | 2024-11-23 17:38:00 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fixed(s) fixed<<setprecision(12)<<s
#define int long long
using namespace std;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef long long ll;
const int N = 200010, mod = 998244353;
ll m, n;
ll fact[N], infact[N], inv[N];
ll C(ll a, ll b)
{
if(a < b)return 0;
return (ll)fact[a] * infact[b] % mod * infact[a - b] % mod;
}
void solve()
{
cin >> m >> n;
if(n == 1)
{
cout << 0;
return;
}
ll ans = 0;
for(int i = 1; i <= m; i ++)
{
int you = m / i - 1;
ll res = C(you, n - 1);
ans = (ans + res) % mod;
//int cnt = 1;
for(int j = i + i; j <= m; j += i)
{
ll beishu = j / i;
int cnt = 2;
ll num = j;
while(num <= m)
{
if(cnt > n)break;
int t_y = m / num - 1;
res = C(t_y, n - cnt);
ans = (ans + res) % mod;
num *= beishu;
cnt ++;
}
}
}
ll ans1 = C(m, n) * n % mod;
ans = (ans1 - ans) % mod;
cout << (ans + mod) % mod;
}
signed main()
{
IOS
fact[0] = fact[1]= infact[0] = infact[1] = inv[1] = 1;
for(int i = 2; i < N; i ++)
{
fact[i] = ((ll)fact[i - 1] * i) % mod;
inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
infact[i] = (ll)infact[i - 1] * inv[i] % mod;
}
//cout << "===" << C(0, 0) << endl;
int _ = 1;
//cin >> _;
while(_ --)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 8240kb
input:
4 3
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 8396kb
input:
11 4
output:
1187
result:
ok 1 number(s): "1187"
Test #3:
score: 0
Accepted
time: 10ms
memory: 8392kb
input:
100000 99999
output:
17356471
result:
ok 1 number(s): "17356471"
Test #4:
score: 0
Accepted
time: 0ms
memory: 8232kb
input:
11451 1919
output:
845616153
result:
ok 1 number(s): "845616153"
Test #5:
score: -100
Wrong Answer
time: 10ms
memory: 8264kb
input:
99998 12345
output:
868880582
result:
wrong answer 1st numbers differ - expected: '936396560', found: '868880582'