QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#744095#9597. Grade 2HalloWorldRE 55ms9036kbC++201.0kb2024-11-13 20:50:512024-11-13 20:50:52

Judging History

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

  • [2024-11-13 20:50:52]
  • 评测
  • 测评结果:RE
  • 用时:55ms
  • 内存:9036kb
  • [2024-11-13 20:50:51]
  • 提交

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=1000010;
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: 3688kb

input:

15 2
1 4
11 4514

output:

2
2252

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 51ms
memory: 8772kb

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
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #3:

score: 0
Accepted
time: 55ms
memory: 9036kb

input:

465262 100000
119442423888 249533375982
528365238401 528365275157
654839906300 654839906303
135820863700 135820967840
336231 918143221477
568175915485 568176067832
993015103483 993015103488
951474 444595379179
298623434750 298623434751
257961 410491919396
996297715292 996297994388
17765498878 177654...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #4:

score: -100
Runtime Error

input:

599394 100000
683408 868635908987
347999512025 347999739145
740945 377178907084
399211757563 399211757568
766968 548821086083
630762 702128377806
756554924031 756554924036
904713771313 904714518208
17026878789 17027129255
11601638470 206412869961
253365321722 253365321730
785476956554 785477402085
2...

output:


result: