QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744090 | #9597. Grade 2 | HalloWorld | RE | 0ms | 3644kb | C++20 | 1.0kb | 2024-11-13 20:49:17 | 2024-11-13 20:49:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define SZ(x) ((int)(x).size())
#define debug(a) cout<<#a<<":"<<a<<endl
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
constexpr int N=100010;
constexpr int INF=2e9;
constexpr ll LLF=2e18;
constexpr ll mod=998244353;
constexpr int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
ll powmod(ll a,ll b,ll mod=mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll inv(ll a){return powmod(a,mod-2);}
ll n,x,l,r,cnt[N];
void solve() {
cin>>x>>n;
ll m=1;
while(m<x) m*=2;
rep(i,1,m) {
cnt[i]=cnt[i-1];
if(__gcd((x*i)^x,x)==1) cnt[i]++;
}
rep(i,1,n){
cin>>l>>r;l--;
auto ansl=cnt[m]*(l/m)+cnt[l%m];
auto ansr=cnt[m]*(r/m)+cnt[r%m];
cout<<(ansr-ansl)<<"\n";
}
}
int main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
// cout << fixed << setprecision(10);
// int testcase;cin>>testcase;rep(_,1,testcase){
solve();
// }
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: -100
Runtime Error
input:
500696 100000 110442401300 646889080214 337192 670162015551 508011001649 508011014425 94418501628 94418501634 824168677375 824168677376 732815842309 795402573302 353241304050 846773277757 622033633276 622033633284 760381702139 760381702143 207714 795408271057 382792 952061527685 686173 331215904334 ...