QOJ.ac

QOJ

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#588#379832#7735. Primitive Root5abucup-team3294Success!2024-04-08 18:15:212024-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'

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379832#7735. Primitive Rootucup-team3294WA 63ms3720kbC++14786b2024-04-06 19:23:212024-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();
    }
}