QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#759470#9553. The Hermitmango09WA 977ms83720kbC++142.1kb2024-11-18 09:04:562024-11-18 09:05:06

Judging History

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

  • [2024-11-18 19:43:48]
  • hack成功,自动添加数据
  • (/hack/1196)
  • [2024-11-18 09:05:06]
  • 评测
  • 测评结果:WA
  • 用时:977ms
  • 内存:83720kb
  • [2024-11-18 09:04:56]
  • 提交

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);
	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 <= ceil(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 <= ceil(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: 4084kb

input:

4 3

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

11 4

output:

1187

result:

ok 1 number(s): "1187"

Test #3:

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

input:

100000 99999

output:

17356471

result:

ok 1 number(s): "17356471"

Test #4:

score: 0
Accepted
time: 31ms
memory: 9496kb

input:

11451 1919

output:

845616153

result:

ok 1 number(s): "845616153"

Test #5:

score: 0
Accepted
time: 954ms
memory: 83720kb

input:

99998 12345

output:

936396560

result:

ok 1 number(s): "936396560"

Test #6:

score: -100
Wrong Answer
time: 977ms
memory: 83636kb

input:

100000 1

output:

575723243

result:

wrong answer 1st numbers differ - expected: '0', found: '575723243'