QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408698#6704. Happy EquationdolphinWA 4ms3548kbC++17608b2024-05-10 21:30:382024-05-10 21:30:38

Judging History

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

  • [2024-05-10 21:30:38]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3548kb
  • [2024-05-10 21:30:38]
  • 提交

answer

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

int t;
int qmi(int a,int b,int mod)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

signed main()
{
    cin>>t;
    while(t--)
    {
        int a,p;
        cin>>a>>p;
        int sum=0;
        int m=1<<p;

        for(int i=1;i<=p;i++)
        {
            if(qmi(a,i,m)==qmi(i,a,m)) sum++;
        }

        int tmp=(p/a)+(p%a==0?0:1);
        sum=sum+(m>>tmp)-(p>>tmp);
        cout<<sum<<endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3548kb

input:

2
6 12
8 16

output:

1023
16383

result:

ok 2 number(s): "1023 16383"

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3504kb

input:

1000
959668315 17
173599849 18
452866086 16
984874375 15
346061855 21
440851881 22
224960642 16
176079916 16
656766412 21
283466925 25
20353211 27
691728649 20
772055116 17
459468637 21
206618043 15
987058694 25
621275781 22
787193761 15
812760680 25
993799948 25
126264161 18
897813346 16
762713004 ...

output:

65528
131063
32761
16377
1048566
2097141
32761
32765
1048571
16777204
67108851
524278
65532
1048566
16377
16777204
2097141
16377
16777212
16777210
131063
32761
16777210
4194293
134217714
33554420
32761
131063
16777204
268435442
2097142
8388603
262142
268435442
4194293
16777204
4194299
134217722
1310...

result:

wrong answer 1st numbers differ - expected: '1', found: '65528'