QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#588 | #379832 | #7735. Primitive Root | 5ab | ucup-team3294 | Success! | 2024-04-08 18:15:21 | 2024-04-08 18:15:21 |
Details
Extra Test:
Wrong Answer
time: 77ms
memory: 3660kb
input:
1 3 605929237970266041
output:
100000000
result:
wrong answer 1st lines differ - expected: '201976412656755348', found: '100000000'
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379832 | #7735. Primitive Root | ucup-team3294 | WA | 63ms | 3720kb | C++14 | 786b | 2024-04-06 19:23:21 | 2024-04-08 18:19:12 |
answer
#include<bits/stdc++.h>
#define int long long
#define PII pair<int,int>
#define x first
#define y second
using namespace std;
const int N=1e5+5;
void solve() {
int p,m;
cin>>p>>m;
int t=p-1;
if(p==2)
{
cout<<m/2+1<<"\n";
}
else
{
int sum=0;
int yt=0;
for(__int128 i=0; i<100000000; i++)
{
if(((i*p+1)^t)<=m)
{
sum++;
}
else
{
if(yt) break;
else yt++;
}
}
cout<<sum<<endl;
}
}
signed main() {
int T=1;
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--)
{
solve();
}
}