# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003392 |
2024-06-20T09:37:53 Z |
vjudge1 |
Party (INOI20_party) |
C++17 |
|
3000 ms |
600 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
ll binpow(ll n, ll p)
{
ll ans = 1;
while (p)
{
ans = (p & 1 ? (ans * n) % mod : ans);
n = (n * n) % mod;
p >>= 1;
}
return ans;
}
ll inv(ll x)
{
return binpow(x, mod - 2);
}
void solve()
{
ll n;
cin >> n;
ll ans = 0, lg = __lg(n);
ll freq[120];
for (ll i = 0; i <= lg; i++)
{
ll res = 0;
for (ll j = 0; j < 120; j++) freq[j] = 0;
for (ll j = 1; j <= i; j++){
freq[j]++;
for (ll x = 1; i - j + x <= lg; x++) freq[j + x] += (1ll << (x - 1));
}
for (ll x = 1; x + i <= lg; x++) freq[x] += (1ll << x);
ll cur = 0;
for (ll j = 119; j >= 0; j--)
res = (res + binpow(2, cur) * (binpow(2, freq[j]) - 1) % mod * j % mod) % mod, cur += freq[j];
ans = (ans + binpow(2, i) * res % mod) % mod;
}
ans = ans * inv(binpow(2, n) - 1 + mod) % mod;
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// precomp();
cin >> t;
for (ll cs = 1; cs <= t; cs++)
solve();
// cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
348 KB |
Output is correct |
2 |
Correct |
102 ms |
348 KB |
Output is correct |
3 |
Correct |
101 ms |
344 KB |
Output is correct |
4 |
Correct |
88 ms |
344 KB |
Output is correct |
5 |
Correct |
102 ms |
344 KB |
Output is correct |
6 |
Correct |
101 ms |
344 KB |
Output is correct |
7 |
Correct |
93 ms |
348 KB |
Output is correct |
8 |
Correct |
95 ms |
348 KB |
Output is correct |
9 |
Correct |
94 ms |
444 KB |
Output is correct |
10 |
Correct |
103 ms |
600 KB |
Output is correct |
11 |
Execution timed out |
3035 ms |
344 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
94 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |