QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601394#9309. GraphAshbourneWA 205ms31400kbC++141.7kb2024-09-29 22:55:082024-09-29 22:55:09

Judging History

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

  • [2024-09-29 22:55:09]
  • 评测
  • 测评结果:WA
  • 用时:205ms
  • 内存:31400kb
  • [2024-09-29 22:55:08]
  • 提交

answer

#include<bits/stdc++.h> 
using namespace std;
#define int long long
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define drp(i, j, k) for(int i = j; i >= k; -- i)
const int N = 8e5 + 10, Mod = 998244353;
int fpow(int a, int b){
	int x = 1;
	while(b){
		if(b & 1) x = x * a % Mod;
		a = a * a % Mod;
		b >>= 1;
	}
	return x;
}
int inv2;
int pri[N], ispri[N], b[N][2], c[N], g[N], w[N], P, E;
void prpr(int n){
	inv2 = fpow(2, Mod - 2);
	rep(i, 1, n) ispri[i] = 1;
	rep(i, 2, n){
		if(ispri[i]){
			pri[++P] = i;
			// c[P] = (c[P - 1] + 1);
		}
		rep(j, 1, P){
			if(i * pri[j] > n) break;
			ispri[i * pri[j]] = 0;
			if(i % pri[j] == 0) break;
		}
	}
}
int ans = 1, z[N];
#define id(x) (x <= E ? b[x][0]: b[n / (x)][1])
void calc(int n){
	E = sqrt(n);
	int t = 0, l = 1, r, q;
	for(; l <= n; l = r + 1){
		q = w[id(n / l) = ++ t] = n / l; r = (n / q);
		z[t] = (r - l + 1);
		int num = w[t] % Mod;
		g[t] = num + Mod - 1;
		g[t] %= Mod;
		// g[t] = (g[t] + Mod - 1) % Mod;
	}
	// cout << t << endl;
	// rep(i, 1, t) cout << g[i] << endl;
	// t--;
	rep(i, 1, P) rep(j, 1, t){
		if(pri[i] * pri[i] > w[j]) break;
		q = id(w[j] / pri[i]);
		g[j] = (g[j] - g[q] + i - 1 + Mod) % Mod;
	}
	rep(i, 1, t){
		q = id(w[i] / 2);
		g[i] = (g[i] - g[q] + Mod) % Mod;
	}
	// rep(i, 1, t) cout << g[i] << endl;
	rep(i, 1, t - 1){
		int m = w[i] % Mod;
		int f_tt = (m - g[i] - 1 + Mod) % Mod * fpow(m, g[i]) % Mod;
		if(f_tt == 0) f_tt = fpow(m, g[i] - 1);
		// cout << f_tt << endl;
		ans = ans * fpow(f_tt, z[i]) % Mod;
	}
	// ans = ans * fpow(fpow(w[t - 1], g[t - 1] - 1), z[t - 1]) % Mod;
	cout << ans << endl;
}
signed main(){
	ios::sync_with_stdio(0);
	prpr(4e5);
	int n; cin >> n;
	calc(n);
	
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 15836kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

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

input:

2

output:

1

result:

ok answer is '1'

Test #3:

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

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

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

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

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

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

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

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

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

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

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

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

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

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 2ms
memory: 16052kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

score: 0
Accepted
time: 7ms
memory: 18360kb

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 18ms
memory: 14760kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

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

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 29ms
memory: 25460kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: 0
Accepted
time: 45ms
memory: 18168kb

input:

5120103302

output:

116870489

result:

ok answer is '116870489'

Test #16:

score: 0
Accepted
time: 107ms
memory: 24668kb

input:

19834593299

output:

523663743

result:

ok answer is '523663743'

Test #17:

score: -100
Wrong Answer
time: 205ms
memory: 31400kb

input:

52500109238

output:

78396536

result:

wrong answer expected '195086665', found '78396536'