QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#300477 | #4937. Permutation Transformation | LeeShoW# | WA | 6ms | 4456kb | C++20 | 1.1kb | 2024-01-08 12:31:35 | 2024-01-08 12:31:35 |
Judging History
answer
#include<algorithm>
#include<iostream>
#include<utility>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#define int long long
#define PB push_back
#define X first
#define Y second
using namespace std;
const int N=1e5+5,MOD=1e9+7;
int v[N]={},ans1[N]={};
bool vis[N]={};
int n,now,k,sum,ans=1,nowk,nowkk;
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>v[i];
for(int i=1;i<=n;i++){
if(vis[i]) continue;
now=i,k=0,sum=0;
while(!vis[now]) vis[now]=true,now=v[now],k++;
while(!(k&1)) sum++,k>>=1;
nowk=max(nowk,sum);
if(k>1){
now=0,nowkk=1,nowkk<<=1,nowkk%=k,now++;
while(nowkk!=1) nowkk<<=1,nowkk%=k,now++;
for(int j=2;j<=now;j++){
sum=0;
while(!(now%j)) sum++,now/=j;
ans1[j]=max(ans1[j],sum);
}
}
}
for(int i=2;i<=n;i++){
while(ans1[i]) ans*=i,ans%=MOD,ans1[i]--;
}
cout<<ans+nowk<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
5 3 5 1 2 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
8 7 5 1 6 8 2 3 4
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 6ms
memory: 4456kb
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:
167174887
result:
wrong answer 1st lines differ - expected: '216333199', found: '167174887'