QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624684#9309. GraphcomplexorAC ✓306ms24816kbC++142.2kb2024-10-09 16:25:392024-10-09 16:25:41

Judging History

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

  • [2024-10-09 16:25:41]
  • 评测
  • 测评结果:AC
  • 用时:306ms
  • 内存:24816kb
  • [2024-10-09 16:25:39]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef __int128 LLL;
typedef std::pair<int, int> pii;
typedef std::pair<LL, int> pli;
typedef std::pair<LL, LL> pll;
typedef unsigned int UI;
typedef std::pair<UI, UI> puu;
#define fi first
#define se second
#define MP std::make_pair
const int MAXN = 1000005, inf = 0x3f3f3f3f, B = 350000;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 998244353;
auto fplus = [](int x, int y){ return x + y >= MOD ? x + y - MOD : x + y; };
auto fminus = [](int x, int y){ return x >= y ? x - y : x + MOD - y; };
auto Fplus = [](int &x, int y){ return x = fplus(x, y); };
auto Fminus = [](int &x, int y){ return x = fminus(x, y); };
template<typename T> T& Fmax(T& x, T y){ return x = x < y ? y : x; };
template<typename T> T& Fmin(T& x, T y){ return x = x < y ? x : y; };
int fpow(int x, LL y = MOD - 2)
{
	int res = 1;
	for (; y; y >>= 1, x = (LL)x * x % MOD)
		if (y & 1) res = (LL)res * x % MOD;
	return res;
}
bool isP[MAXN];
int p[MAXN], cP;
LL n;
void Euler(int n)
{
	memset(isP + 1, true, n);
	isP[1] = false;
	for (int i = 2; i <= n; i++)
	{
		if (isP[i]) p[++cP] = i;
		for (int j = 1; p[j] <= n / i; j++)
		{
			isP[i * p[j]] = false;
			if (i % p[j] == 0) break;
		}
	}
}
LL val[MAXN], f[MAXN];
int id[MAXN], tot , m;
int& ID(LL x){ return x <= B ? id[x] : id[n / x + B]; }
void init_25()
{
	tot = 0;
	for (LL l = 1, r; l <= n; l = r + 1)
		r = n / (n / l), val[ID(n / l) = ++tot] = n / l;
	for (m = 0; p[m + 1] <= n / p[m + 1]; m++) ;
}
void min_25()
{
	init_25();
	for (LL l = 1, r; l <= n; l = r + 1)
		r = n / (n / l), f[ID(n / l)] = n / l;
	for (int i = 1; i <= m; i++)
		for (int j = 1; p[i] <= val[j] / p[i]; j++)
			f[j] -= f[ID(val[j] / p[i])] - i;
}
LL count(LL x){ return f[ID(x)] - f[ID(x / 2)]; }
int calc(LL x)
{
	if (x <= 2) return 1;
	if (x == 3) return 3;
	LL c = count(x);
//	printf("%lld: %lld\n", x, c);
	return (x - c - 1) % MOD * fpow(x % MOD, c) % MOD;
}
int main()
{
	scanf("%lld", &n);
	Euler(B), min_25();
	int ans = 1;
	for (LL l = 1, r; l <= n; l = r + 1)
		r = n / (n / l), ans = (LL)ans * fpow(calc(n / l), r - l + 1) % MOD;
	printf("%d\n", ans);
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 12012kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 3ms
memory: 10440kb

input:

2

output:

1

result:

ok answer is '1'

Test #3:

score: 0
Accepted
time: 3ms
memory: 10292kb

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

score: 0
Accepted
time: 3ms
memory: 12136kb

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

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

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

score: 0
Accepted
time: 3ms
memory: 12100kb

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

score: 0
Accepted
time: 3ms
memory: 12452kb

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

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

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

score: 0
Accepted
time: 3ms
memory: 12236kb

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 4ms
memory: 13392kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

score: 0
Accepted
time: 6ms
memory: 11744kb

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 14ms
memory: 15384kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

score: 0
Accepted
time: 14ms
memory: 14540kb

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 23ms
memory: 15464kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: 0
Accepted
time: 41ms
memory: 15812kb

input:

5120103302

output:

116870489

result:

ok answer is '116870489'

Test #16:

score: 0
Accepted
time: 101ms
memory: 19620kb

input:

19834593299

output:

523663743

result:

ok answer is '523663743'

Test #17:

score: 0
Accepted
time: 198ms
memory: 20672kb

input:

52500109238

output:

195086665

result:

ok answer is '195086665'

Test #18:

score: 0
Accepted
time: 271ms
memory: 23756kb

input:

84848352911

output:

107959260

result:

ok answer is '107959260'

Test #19:

score: 0
Accepted
time: 301ms
memory: 24816kb

input:

99824435322

output:

0

result:

ok answer is '0'

Test #20:

score: 0
Accepted
time: 306ms
memory: 23324kb

input:

99999999354

output:

316301711

result:

ok answer is '316301711'

Test #21:

score: 0
Accepted
time: 302ms
memory: 23616kb

input:

100000000000

output:

396843576

result:

ok answer is '396843576'

Extra Test:

score: 0
Extra Test Passed