#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define oo 1e9
const int MAX = 203, MOD = 1e9 + 7, LOGMAX = 130;
int n;
int pw[MAX];
int Hcnt[LOGMAX][LOGMAX];
int RHcnt[LOGMAX][LOGMAX];
int binpow(int a, int b){
if(b == 0) return 1;
if(b & 1) return binpow(a, b - 1) % MOD * a % MOD;
else return binpow(a * a % MOD, b / 2) % MOD;
}
int inv(int a){
return binpow(a, MOD - 2);
}
void solve(){
cin >> n;
int ans = 0;
int LG = log2(n);
for(int i = 0; (1 << i) <= n; i++){
for(int j = 0; j <= LG + i; j++){
Hcnt[i][j] = 0;
RHcnt[i][j] = 0;
}
for(int j = 0; j <= LG - i; j++){
Hcnt[i][j] = (1 << j);
RHcnt[i][j] = (1 << max(0ll, j - 1));
}
if(i != 0){
for(int j = 0; j <= LG + i - 1; j++){
RHcnt[i][j + 1] += RHcnt[i - 1][j];
Hcnt[i][j + 1] += RHcnt[i - 1][j];
}
}
// for(int j = 0; j <= LG + i; j++) cout << Hcnt[i][j] << ' ';
// cout << '\n';
int oth = n;
for(int j = 0; j <= LG + i; j++){
oth -= Hcnt[i][j];
ans = (ans + pw[i] * j % MOD * (pw[Hcnt[i][j]] - 1) % MOD * pw[oth] % MOD) % MOD;
}
}
cout << ans * inv(pw[n]) % MOD << '\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
pw[0] = 1;
for(int i = 1; i < MAX; i++){
pw[i] = pw[i - 1] * 2 % MOD;
}
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |