QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#844719 | #3472. EvenOdd | harlem | AC ✓ | 0ms | 3708kb | C++20 | 1.5kb | 2025-01-06 10:31:40 | 2025-01-06 10:31:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
typedef double db;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
template <typename Type>
using vec=vector<Type>;
template <typename Type>
using grheap=priority_queue<Type>;
template <typename Type>
using lrheap=priority_queue<Type,vector<Type>,greater<Type> >;
#define fir first
#define sec second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;
const int T=64;
ll cft[T];
void init(ll rb){
cft[0]=1;
rep(i,1,inf){
cft[i]=cft[i-1]*2;
if((1ll<<i)>=rb)break;
}
}
ll l,r;
ll f(ll x){
ll res=0;
while(x>1){
if(x&1)x++;
else x>>=1;
res++;
}
return res;
}
ll getans(ll num){
if(num<=1)return 0;
if(num&1)return (getans(num-1)+f(num))%mod;
return (((num/2+2*getans(num/2)%mod)%mod+num%mod)%mod-2+mod)%mod;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>l>>r;
init(r);
cout<<(getans(r)-getans(l-1)+mod)%mod;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
1 127
output:
1083
result:
ok single line: '1083'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
74 74
output:
11
result:
ok single line: '11'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
188481480076382025 735477894373585094
output:
603589184
result:
ok single line: '603589184'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
221018194823646727 598132723231895586
output:
593435414
result:
ok single line: '593435414'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
723254527395008082 857000792713570284
output:
130769773
result:
ok single line: '130769773'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
308610764995277671 886546357678103983
output:
981434297
result:
ok single line: '981434297'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
467129058436471616 929946560335162000
output:
956030241
result:
ok single line: '956030241'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
142308250729181166 793647580012269898
output:
890073540
result:
ok single line: '890073540'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
30010612464177072 225060844674934062
output:
192815207
result:
ok single line: '192815207'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
1 1000000000000000000
output:
826523937
result:
ok single line: '826523937'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 999999999999999999
output:
826523858
result:
ok single line: '826523858'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 16384
output:
311294
result:
ok single line: '311294'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
4398046511104 18014398509481984
output:
451815097
result:
ok single line: '451815097'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4096 281474976710656
output:
231757660
result:
ok single line: '231757660'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
16 137438953472
output:
983959228
result:
ok single line: '983959228'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
8192 16777216
output:
570281997
result:
ok single line: '570281997'