ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214924 | #3855. 好数 | Anthonyyan | 0 | 30ms | 1128kb | C++ | 1.9kb | 2024-11-24 09:23:38 | 2024-11-24 13:14:25 |
answer
#include <bits/stdc++.h>
#define int long long
#define pll pair<int, int>
#define rep(i, s, e, st) for (int i = s, __##i = e; i <= __##i; i += st)
#define per(i, s, e, st) for (int i = s, __##i = e; i <= __##i; i -= st)
#define lowbit(x) ((x) & (-(x)))
#define lc(x) ((x) << 1)
#define rc(x) (((x) << 1) | 1)
#define clr(dst, size) memset(dst, 0, (sizeof(int)) * size)
#define initval(dst, val, size) memset(dst, val, (sizeof(int)) * size)
#define cpy(from, to, size) memcpy(from, to, (sizeof(int)) * size)
#define mid(l, r) (((l) + (r)) >> 1)
#define min Min
#define max Max
#define abs Abs
#define gc getchar()
inline int read()
{
int x = 0, f = 1;
char ch = gc;
while (!isdigit(ch))
{
if (ch == '-')
f = -f;
ch = gc;
}
while (isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch - '0');
ch = gc;
}
return x * f;
}
inline void write(int x)
{
if (x < 0)
putchar('-'), x = -x;
if (x / 10)
write(x / 10);
putchar('0' + x % 10);
}
template <typename T>
T Abs(T x) { return x < 0 ? -x : x; }
template <typename T, typename TT>
T Min(T x, TT y) { return x < y ? x : y; }
template <typename T, typename TT>
T Max(T x, TT y) { return x > y ? x : y; }
using namespace std;
const int MAXN = 1e9 + 10;
int ppc(int x)
{
int cnt = 0;
while ((x & 1) == 0 && x)
{
cnt++;
x >>= 1;
}
return cnt;
}
int ctz(int x)
{
int cnt = 0;
while (x)
{
cnt += (x & 1);
x >>= 1;
}
return cnt;
}
int l, r;
int q;
signed main()
{
#ifndef ONLINE_JUDGE
freopen("good.in", "r", stdin);
freopen("good.out", "w", stdout);
#endif
q = read();
while (q--)
{
l = read(), r = read();
bool found = false;
rep(i, l, r, 1) if (ctz(i) == ppc(i))
{
write(i), putchar('\n');
found = true;
break;
}
if (!found)
puts("-1");
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 30
Accepted
time: 0ms
memory: 1128kb
input:
1 999995700 1000000000
output:
-1
result:
ok Accepted! >_<
Test #2:
score: -30
Time Limit Exceeded
input:
100000 7857167 7862247 8344618 8348655 8382478 8388566 8315927 8321011 8246290 8250342 8382480 83885...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8370176 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #13:
score: 30
Accepted
time: 30ms
memory: 1124kb
input:
100000 8382464 8388612 7332864 7337984 8250368 8255488 8119296 8124416 8373248 8378368 8348672 83537...
output:
8382464 7332864 8250368 8119296 8373248 8348672 8315904 4187136 8246272 8311808 8344576 6280192 4174...
result:
ok Accepted! >_<
Test #14:
score: -30
Time Limit Exceeded
input:
100000 330807594 855120061 2739043 698283851 6893055 483485075 87223028 335275196 436165546 84345741...
output:
330813440 2739456 6893696 87223296 436166656 184620160 878068224 321856512 421955072 518016000 16218...
result:
Subtask #3:
score: 0
Skipped