QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#1144 | #721837 | #7735. Primitive Root | liuenci | paramec1um | Failed. | 2024-11-07 17:01:05 | 2024-11-07 17:01:05 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3588kb
input:
8 37 26 83 54 97 93 997 121 998244353 367122943 1000000007 123456789 2147483647 987654321 31 623547866135642778
output:
1 1 1 1 1 1 0 20114447294698155
result:
ok 8 lines
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#721837 | #7735. Primitive Root | paramec1um# | AC ✓ | 25ms | 3712kb | C++20 | 489b | 2024-11-07 16:58:32 | 2024-11-07 16:58:33 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
ll n,m;cin>>n>>m;
ll tmp=m/n;
ll ans=tmp;
for(ll i=max(tmp-3,0LL);i<=tmp+3;++i){
//cout<<i<<':'<<ans<<' '<<((tmp*n+1)^(n-1))<< '\n';
if((((i*n+1)^(n-1))<=m)&&i>tmp)ans++;
if((((i*n+1)^(n-1))>m)&&i<=tmp)ans--;
}
cout<<ans+1<<'\n';
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t=1;cin>>t;
while(t--)solve();
}