QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#344872 | #3812. Sheldon Numbers | PetroTarnavskyi# | AC ✓ | 1ms | 3980kb | C++20 | 1.2kb | 2024-03-05 16:52:37 | 2024-03-05 16:52:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
vector<LL> vals;
FOR(n, 1, 64)
{
FOR(m, 1, 63)
{
FOR(cnt, 1, 64)
{
int cnt1 = (cnt + 1) / 2;
int cnt0 = (cnt) / 2;
if(cnt1 * n + cnt0 * m > 63)
break;
__int128 val1 = 1;
val1 = (val1 << n) - 1;
LL sum = 0;
FOR(i, 0, cnt)
{
if(i % 2 == 0)
{
sum = (sum << n) + val1;
}
else
sum = (sum << m);
}
if(cnt != 1 || m == 1)
{
vals.PB(sum);
}
}
}
}
sort(ALL(vals));
vals.resize(unique(ALL(vals)) - vals.begin());
LL l, r;
cin >> l >> r;
int ans = 0;
for(LL i : vals)
{
ans += (l <= i && i <= r);
}
cout << ans << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3980kb
input:
1 10
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
70 75
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3972kb
input:
0 9223372036854775807
output:
4809
result:
ok single line: '4809'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
99 99
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
231 231
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
3171 3171
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
7399 7399
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
792 792
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
924 924
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
25368 25368
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
29596 29596
output:
1
result:
ok single line: '1'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
100 100
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
100 111
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
232 232
output:
0
result:
ok single line: '0'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3972kb
input:
3172 3172
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
7400 7400
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
793 793
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
925 925
output:
0
result:
ok single line: '0'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
25369 25369
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
29597 29597
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
1700 1799
output:
3
result:
ok single line: '3'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
10 1000
output:
84
result:
ok single line: '84'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
100 100000
output:
241
result:
ok single line: '241'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
1000 10000000
output:
492
result:
ok single line: '492'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
10000 1000000000
output:
799
result:
ok single line: '799'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
100000 100000000000
output:
1250
result:
ok single line: '1250'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
1000000 10000000000000
output:
1769
result:
ok single line: '1769'