QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#374831#3051. Identity FunctionSolitaryDream#WA 1ms3832kbC++171014b2024-04-02 18:42:402024-04-02 18:42:40

Judging History

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

  • [2024-04-02 18:42:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2024-04-02 18:42:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

const int N=1e5+1e3+7;

int phi(int x)
{
    int ans=x;
    for(int i=2;i*i<=x;i++)
        if(x%i==0)
        {
            ans=ans/i*(i-1);
            while(x%i==0)
                x/=i;
        }
    if(x!=1)
        ans=ans/x*(x-1);
    return ans;
}

int qpow(int a,int b,int P)
{
    int ret=1;
    while(b)
    {
        if(b&1)
            ret=ret*a%P;
        b>>=1;
        a=a*a%P;
    }
    return ret%P;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int w=phi(phi(n));
    int pn=phi(n);
    vector<int> ans;
    for(int i=1;i*i<=w;i++)
        if(w%i==0)
        {
            if(qpow(n,i,pn)==1%pn)
                ans.push_back(i);
            if(qpow(n,w/i,pn)==1%pn)
                ans.push_back(w/i);
        }
    if(ans.size())
        cout<<*min_element(ans.begin(),ans.end())<<"\n";
    else
        cout<<"-1\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

3

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

4

output:

-1

result:

ok single line: '-1'

Test #3:

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

input:

15

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

2

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

3

output:

1

result:

ok single line: '1'

Test #6:

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

input:

4

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

5

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

6

output:

-1

result:

ok single line: '-1'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

7

output:

1

result:

ok single line: '1'

Test #10:

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

input:

8

output:

-1

result:

ok single line: '-1'

Test #11:

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

input:

9

output:

-1

result:

ok single line: '-1'

Test #12:

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

input:

10

output:

-1

result:

ok single line: '-1'

Test #13:

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

input:

11

output:

1

result:

ok single line: '1'

Test #14:

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

input:

12

output:

-1

result:

ok single line: '-1'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

13

output:

1

result:

ok single line: '1'

Test #16:

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

input:

14

output:

-1

result:

ok single line: '-1'

Test #17:

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

input:

15

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

16

output:

-1

result:

ok single line: '-1'

Test #19:

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

input:

17

output:

1

result:

ok single line: '1'

Test #20:

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

input:

18

output:

-1

result:

ok single line: '-1'

Test #21:

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

input:

19

output:

1

result:

ok single line: '1'

Test #22:

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

input:

20

output:

-1

result:

ok single line: '-1'

Test #23:

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

input:

21

output:

-1

result:

ok single line: '-1'

Test #24:

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

input:

140232429

output:

-1

result:

ok single line: '-1'

Test #25:

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

input:

21672344

output:

-1

result:

ok single line: '-1'

Test #26:

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

input:

229029120

output:

-1

result:

ok single line: '-1'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

511616301

output:

-1

result:

ok single line: '-1'

Test #28:

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

input:

4353750

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

9129172

output:

-1

result:

ok single line: '-1'

Test #30:

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

input:

256102461

output:

-1

result:

ok single line: '-1'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

477992350

output:

-1

result:

ok single line: '-1'

Test #32:

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

input:

28628975

output:

-1

result:

ok single line: '-1'

Test #33:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

324852814

output:

-1

result:

ok single line: '-1'

Test #34:

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

input:

3675825

output:

-1

result:

ok single line: '-1'

Test #35:

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

input:

59900148

output:

-1

result:

ok single line: '-1'

Test #36:

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

input:

53150292

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

194354668

output:

-1

result:

ok single line: '-1'

Test #38:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

72185553

output:

-1

result:

ok single line: '-1'

Test #39:

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

input:

423042624

output:

-1

result:

ok single line: '-1'

Test #40:

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

input:

1225588

output:

-1

result:

ok single line: '-1'

Test #41:

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

input:

144315184

output:

-1

result:

ok single line: '-1'

Test #42:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

170662393

output:

-1

result:

ok single line: '-1'

Test #43:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

4746825

output:

-1

result:

ok single line: '-1'

Test #44:

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

input:

429865917

output:

-1

result:

ok single line: '-1'

Test #45:

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

input:

119075974

output:

-1

result:

ok single line: '-1'

Test #46:

score: -100
Wrong Answer
time: 0ms
memory: 3548kb

input:

82251853

output:

20160

result:

wrong answer 1st lines differ - expected: '5040', found: '20160'