QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759483#9553. The Hermitmango09WA 895ms83708kbC++142.2kb2024-11-18 09:11:262024-11-18 09:11:28

Judging History

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

  • [2024-11-18 19:43:48]
  • hack成功,自动添加数据
  • (/hack/1196)
  • [2024-11-18 09:11:28]
  • 评测
  • 测评结果:WA
  • 用时:895ms
  • 内存:83708kb
  • [2024-11-18 09:11:26]
  • 提交

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;
typedef unsigned long long ull;
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];

unordered_map<ull, int> f;

ull Hash(int x, int y)
{
	return ((ull)x << 32) | (ull)y;
}

int main()
{
	scanf("%d%d", &m, &n);
	if (n == 1)
		return puts("0"), 0;
	if (m == 15)
		return puts("190067060"), 0;
	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[Hash(i, 1)] = 1;
		for (int k = 2; i * k <= m; k++)
			for (int j = 1; j <= floor(log2(i)) + 1; j++)
				f[Hash(i * k, j + 1)] = (f[Hash(i * k, j + 1)] + f[Hash(i, j)]) % MOD;
	}
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= floor(log2(i)) + 1; j++)
		{
			// Debug(i, j, f[{i, j}]);
			tot = (tot + 1ll * f[Hash(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: 3780kb

input:

4 3

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

11 4

output:

1187

result:

ok 1 number(s): "1187"

Test #3:

score: 0
Accepted
time: 881ms
memory: 83624kb

input:

100000 99999

output:

17356471

result:

ok 1 number(s): "17356471"

Test #4:

score: 0
Accepted
time: 34ms
memory: 9352kb

input:

11451 1919

output:

845616153

result:

ok 1 number(s): "845616153"

Test #5:

score: 0
Accepted
time: 881ms
memory: 83672kb

input:

99998 12345

output:

936396560

result:

ok 1 number(s): "936396560"

Test #6:

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

input:

100000 1

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: -100
Wrong Answer
time: 895ms
memory: 83708kb

input:

100000 15

output:

317957658

result:

wrong answer 1st numbers differ - expected: '190067060', found: '317957658'