QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759463#9553. The Hermitmango09TL 0ms4064kbC++142.0kb2024-11-18 09:01:482024-11-18 09:01:50

Judging History

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

  • [2024-11-18 19:43:48]
  • hack成功,自动添加数据
  • (/hack/1196)
  • [2024-11-18 09:01:50]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:4064kb
  • [2024-11-18 09:01:48]
  • 提交

answer

// Ice cream? I scream! 
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
	#define freopen Chitanda
#endif
#define wjy namespace
#define xsy std
typedef long long ll;
using wjy xsy;

template<typename T> void debug(string s, T x) {cerr << " " << s << " = " << x << " \n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i = 0, b = 0; i < (int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;else if (s[i] == ')' || s[i] == '}') b--;else if (s[i] == ',' && b == 0) {cerr << " " << s.substr(0, i) << " = " << x << " |";debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);break;}}
#ifdef ONLINE_JUDGE
	#define Debug(...)
#else
	#define Debug(...) debug(#__VA_ARGS__, __VA_ARGS__)
#endif

const int MAXN = 1e5 + 5;
const int MOD = 998244353;
int Qpow(int a, int b) {int base = a, ans = 1; while (b) {if (b & 1) ans = 1ll * ans * base % MOD; base = 1ll * base * base % MOD; b >>= 1;} return ans;}
int Inv(int a) {return Qpow(a, MOD - 2);}

int fac[MAXN], ifac[MAXN];

void Init(int n)
{
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[n] = Inv(fac[n]);
	for (int i = n - 1; ~i; i--)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % MOD;
}

int C(int n, int m)
{
	if (n < m)
		return 0;
	return 1ll * fac[n] * ifac[n - m] % MOD * ifac[m] % MOD;
}

int m, n, cnt;
int d[MAXN];

map<pair<int, int>, int> f;

int main()
{
	scanf("%d%d", &m, &n);
	Init(m);
	int ans = 1ll * n * C(m, n) % MOD, tot = 0;
	// Debug(C(m, n), ans);
	for (int i = 1; i <= m; i++)
	{
		f[{i, 1}] = 1;
		for (int k = 2; i * k <= m; k++)
			for (int j = 1; j <= ceil(log2(i)) + 1; j++)
				f[{i * k, j + 1}] = (f[{i * k, j + 1}] + f[{i, j}]) % MOD;
	}
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= ceil(log2(i)) + 1; j++)
		{
			// Debug(i, j, f[{i, j}]);
			tot = (tot + 1ll * f[{i, j}] * C((m / i) - 1, n - j) % MOD) % MOD;
		}
	}
	// Debug(tot);
	// tot = (tot + 1ll * (n - 1) * cnt % MOD) % MOD;
	printf("%d\n", (ans - tot + MOD) % MOD);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4064kb

input:

4 3

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

11 4

output:

1187

result:

ok 1 number(s): "1187"

Test #3:

score: -100
Time Limit Exceeded

input:

100000 99999

output:


result: