1 条题解
-
0
不大于 且 值不小于 的数字个数为:
对 值差分后累加即可。
#include <bits/stdc++.h> using namespace std; inline __int128 read() { __int128 x = 0; char c = getchar_unlocked(); while (c < '0') c = getchar_unlocked(); while (c >= '0') { x = x * 10 + c - '0'; c = getchar_unlocked(); } return x; } void write(__int128 x) { if (x <= 9) { putchar_unlocked(x + '0'); return; } write(x / 10); putchar_unlocked(x % 10 + '0'); } inline void writeline(__int128 x) { write(x); putchar_unlocked('\n'); } int main() { int T = read(); while (T--) { long long n = read(); __int128 a = n; for (long long i = 1; (n >> i) >= 1; i++) a += n >> i << (i - 1); writeline(a); } return 0; }
信息
- ID
- 274
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 4
- 标签
- 递交数
- 2
- 已通过
- 2
- 上传者