# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003333 |
2024-06-20T09:01:21 Z |
vjudge1 |
Party (INOI20_party) |
C++17 |
|
3000 ms |
1048576 KB |
#include <bits/stdc++.h>
#pragma optimize("O3")
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 = 2e18 + 8, MOD = 1e9 + 7, LOGMAX = 200;
int n;
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 = 0;
int T = 1;
while(T <= n / 2){LG++; T *= 2;};
// if(n != (1ll << (LG + 1)) - 1){
// cout << "0\n";
// return;
// }
for(int i = 0; (1ll << 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] = (1ll << j);
RHcnt[i][j] = (1ll << 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 + j * (binpow(2, Hcnt[i][j]) - 1 + MOD) % MOD * binpow(2, oth + i) % MOD) % MOD;
}
}
cout << ans * inv((binpow(2, n) - 1 + MOD) % MOD) % MOD << '\n';
}
signed main(){
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int t; cin >> t;
while(t--){
solve();
}
}
Compilation message
Main.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize("O3")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
614 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
600 KB |
Output is correct |
2 |
Correct |
282 ms |
612 KB |
Output is correct |
3 |
Correct |
226 ms |
612 KB |
Output is correct |
4 |
Correct |
194 ms |
612 KB |
Output is correct |
5 |
Correct |
255 ms |
440 KB |
Output is correct |
6 |
Correct |
236 ms |
604 KB |
Output is correct |
7 |
Correct |
220 ms |
604 KB |
Output is correct |
8 |
Correct |
221 ms |
600 KB |
Output is correct |
9 |
Correct |
210 ms |
604 KB |
Output is correct |
10 |
Correct |
237 ms |
600 KB |
Output is correct |
11 |
Execution timed out |
3014 ms |
628 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
601 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
614 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |