QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133508 | #4937. Permutation Transformation | nameless_story# | WA | 8ms | 5628kb | C++14 | 1.1kb | 2023-08-02 10:22:59 | 2023-08-02 10:22:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 120000
const int mod=998244353;
int f[N],vis[N],ok[N],gg[N],g[N],h[N];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int n; cin>>n;
for (int i=1;i<=n;++i){
g[i]=i&1?i:g[i/2];
h[i]=i&1?0:h[i/2]+1;
}
for (int i=1;i<=n;++i){
int x; cin>>x;
f[i]=x;
}
long long ans=1;
int tmp=0;
for (int i=1;i<=n;++i){
if (vis[i]) continue;
int x=i;
int cnt=0;
while (!vis[x]){
vis[x]=1;
++cnt;
x=f[x];
}
tmp=max(tmp,h[cnt]);
// cerr<<cnt<<endl;
ok[g[cnt]-1]=1;
}
for (int i=2;i<=n;++i){
if (gg[i]) continue;
for (int j=i*2;j<=n;j+=i){
gg[j]=1;
if (ok[j]){
int x=j,cnt=0;
while (x%i==0){
++cnt;
x/=i;
}
ok[i]=max(ok[i],cnt);
}
}
for (;ok[i];--ok[i]) ans=ans*i%mod;
}
cout<<(ans+tmp)%mod<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 5512kb
input:
5 3 5 1 2 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
8 7 5 1 6 8 2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5576kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 5628kb
input:
100000 20864 34918 58550 1465 75674 30743 27235 88900 47488 50029 46054 84871 20330 72228 16506 44561 92519 97750 82891 60324 90508 39290 24663 38077 90189 30671 95476 64027 70888 90749 22566 8525 33675 16635 23392 97636 35788 89625 41966 78051 94034 15407 26545 83799 2233 10873 56946 71566 19045 44...
output:
32660679
result:
wrong answer 1st lines differ - expected: '216333199', found: '32660679'