0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 17:18:49 +00:00

P5177 签到

https://www.luogu.com.cn/record/81665615
This commit is contained in:
Baoshuo Ren 2022-07-29 15:28:28 +08:00
parent 61b9e71152
commit b0cbb43a3f
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

39
Luogu/P5177/P5177.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
#include <algorithm>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int mod = 1e9 + 7;
const int N = 70;
int t;
long long n, s[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 1; i < 64; i++) {
long long x = ((1ll << i) - 1) % mod;
s[i] = (s[i - 1] + x * (x + 1) / 2) % mod;
}
cin >> t;
while (t--) {
cin >> n;
int x = 64 - __builtin_clzll(n) - 1;
n = (n - (1ll << x)) % mod;
cout << ((s[x - 1] << 1) % mod + n * (n + 1) % mod) % mod << endl;
}
return 0;
}