QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643585#7735. Primitive Rootcy325WA 1ms3648kbC++201.3kb2024-10-15 22:11:032024-10-15 22:11:05

Judging History

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

  • [2024-10-15 22:11:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2024-10-15 22:11:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
    int p,m;
    cin>>p>>m;
    if(p==1){
        cout<<m<<endl;
        return;
    }else if(m==0){
        if(((p-1)^(1))<=m){
            cout<<1<<endl;
            return;
        }else{
            cout<<0<<endl;
            return;
        }
    }else{
        int idx;
        if(p%2==0){  idx= m / p;}

        else { idx = m / p + 1; }
        int cnt=idx;
        if(((p-1)^(idx*p+1))<=m){
            cnt++;
            return;
        }
        if(((p-1)^((idx-1)*p+1))>m){
            cnt--;
        }else if(((p-1)^((idx+1)*p+1))<=m){
            cnt++;
        }
        cout<<cnt<<endl;
        return;
    }
//    int i=0;
//    int cnt=0;
//    int last=p;
//    vector<int> a;
//    while(1){
//        int x=(p-1)^(i*p+1);
////        if(last>m&&x>m)break;
//        if(last>m*2024)break;
//        if(x<=m) {
//            cnt++;a.push_back(x);
//        }
//        cout<<"idx:"<<i<<" x:"<<x<<" ";
//        last=x;
//        i++;
//    }
//    cout<<endl;
//    for(int i=0;i<a.size();i++){cout<<a[i]<<" ";}
//    cout<<a.size()<<endl;
//    cout<<endl;

}
signed main() {
    std::ios::sync_with_stdio(false);

    int t;
    cin>>t;
    while(t--)solve();
//    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3648kb

input:

3
2 0
7 11
1145141 998244353

output:

1
872

result:

wrong answer 2nd lines differ - expected: '2', found: '872'