# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
966585 |
2024-04-20T05:41:39 Z |
manizare |
Party (INOI20_party) |
C++14 |
|
3000 ms |
444 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define ld long double
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define int long long
#define PII pair<pii , pii>
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
#define deb(x) cout <<#x << " : " << x << "\n" ;
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 3e5 + 10, inf = 1e9+10 , mod = 1e9 + 7 ;
int po(int a,int b){
if(b==0)return 1 ;
int v =po(a,b/2);
v=v *v % mod ;
if(b&1) v= v*a % mod;
return v;
}
int k ;
int ch(int x ,int d){
if(d==-1)return 0;
d = min(d , k-x-1);
return ((1ll<<(d+1))-1+mod)%mod ;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t ;
cin >> t ;
while(t--){
int n ;
cin >> n ;
n++ ;
k = 0 ; int T =1 ;
while(T !=n){
T*=2 ;
k++;
}
n--;
int o= 0 ;
rep(i , 0 , k-1){
rep(d , 0 , 2*k+2){
int ans = ch(i , d) ;
int x = i-1 , D = d-1 ;
while(x!=-1 && D!=-1){
ans++ ;
ans = (ans + ch(x+1 , D-1));
D--;
x--;
}
o = (o + (po(2 ,(n-ans))-1+mod)*po(2 , i)%mod + mod)%mod ;
}
}
cout << o*po(po(2,n)-1+mod, mod-2)%mod << "\n";
}
return 0 ;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3067 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
190 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3063 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3067 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |