Submission #966586

#TimeUsernameProblemLanguageResultExecution timeMemory
966586manizareParty (INOI20_party)C++14
0 / 100
3061 ms544 KiB
#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); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...