QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#408698 | #6704. Happy Equation | dolphin | WA | 4ms | 3548kb | C++17 | 608b | 2024-05-10 21:30:38 | 2024-05-10 21:30:38 |
Judging History
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;
}
詳細信息
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'