QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#776122#9553. The HermitChihiroWA 10ms8396kbC++171.5kb2024-11-23 17:38:002024-11-23 17:38:00

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 17:38:00]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:8396kb
  • [2024-11-23 17:38:00]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'