QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574864#9309. GraphNTTAC ✓452ms19512kbC++231.2kb2024-09-19 03:22:532024-09-19 03:22:53

Judging History

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

  • [2024-09-19 03:22:53]
  • 评测
  • 测评结果:AC
  • 用时:452ms
  • 内存:19512kb
  • [2024-09-19 03:22:53]
  • 提交

answer

#pragma GCC optimize("Ofast,inline,unroll-loops")
#include<bits/stdc++.h>
using ll=long long;
constexpr int B=320000,M=998244353;
auto qpow(ll a,auto b){int res=1;for(;b;a=a*a%M,b>>=1)if(b&1)res=res*a%M;return res;}
int v[B];
std::vector<int>prime;
ll n;
using Info=std::array<ll,2*B>;
auto&access(Info&a,ll x){
	if(x<=B)return a[x+B];
	return a[n/x];
}
signed main(){
	v[1]=1;
	prime.reserve(27608);
	for(int i=2;i<B;++i){
		if(!v[i]){
			v[i]=i;
			prime.emplace_back(i);
		}
		for(auto&p:prime){
			if(i*p>=B)break;
			v[i*p]=p;
			if(v[i]==p)break;
		}
	}
	std::cin>>n;
	std::vector<ll>b;
	Info f={};
	for(ll l=1,r;l<=n;l=r+1){
		ll q=n/l;
		r=n/q;
		b.emplace_back(q);
		access(f,q)=q-1;
	}
	for(int j=0;j<ssize(prime);++j){
		for(int i=0;prime[j]*(ll)prime[j]<=b[i];++i){
			access(f,b[i])-=access(f,b[i]/prime[j])-j;
		}
	}
	ll ans=1;
	for(ll l=1,r;l<=n;l=r+1){
		ll q=n/l;
		r=n/q;
		// std::cerr<<l<<' '<<r<<' '<<q<<'\n';
		ans=(ans*qpow([&]->ll{
			if(q==1)return 1;
			if(q==2)return 1;
			if(q==3)return 3;
			// int c=pi[q]-pi[q/2];
			ll c=access(f,q)-access(f,q/2);
			return (q-c-1)%M*qpow(q%M,c)%M;
		}()%M,r-l+1))%M;
	}
	printf("%lld\n",ans);
}

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

详细

Test #1:

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

input:

4

output:

8

result:

ok answer is '8'

Test #2:

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

input:

2

output:

1

result:

ok answer is '1'

Test #3:

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

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

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

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

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

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

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

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

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

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

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

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

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

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

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

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

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

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 19ms
memory: 10184kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

score: 0
Accepted
time: 15ms
memory: 10328kb

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 26ms
memory: 10512kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: 0
Accepted
time: 48ms
memory: 11700kb

input:

5120103302

output:

116870489

result:

ok answer is '116870489'

Test #16:

score: 0
Accepted
time: 121ms
memory: 14940kb

input:

19834593299

output:

523663743

result:

ok answer is '523663743'

Test #17:

score: 0
Accepted
time: 269ms
memory: 13856kb

input:

52500109238

output:

195086665

result:

ok answer is '195086665'

Test #18:

score: 0
Accepted
time: 382ms
memory: 19512kb

input:

84848352911

output:

107959260

result:

ok answer is '107959260'

Test #19:

score: 0
Accepted
time: 436ms
memory: 18056kb

input:

99824435322

output:

0

result:

ok answer is '0'

Test #20:

score: 0
Accepted
time: 449ms
memory: 18600kb

input:

99999999354

output:

316301711

result:

ok answer is '316301711'

Test #21:

score: 0
Accepted
time: 452ms
memory: 18568kb

input:

100000000000

output:

396843576

result:

ok answer is '396843576'

Extra Test:

score: 0
Extra Test Passed