Submission #966588

# Submission time Handle Problem Language Result Execution time Memory
966588 2024-04-20T05:43:43 Z manizare Party (INOI20_party) C++14
0 / 100
3000 ms 624 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);
}

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 3085 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 432 KB Output is correct
2 Correct 135 ms 440 KB Output is correct
3 Correct 121 ms 452 KB Output is correct
4 Correct 106 ms 348 KB Output is correct
5 Correct 126 ms 348 KB Output is correct
6 Correct 123 ms 440 KB Output is correct
7 Correct 112 ms 436 KB Output is correct
8 Correct 118 ms 440 KB Output is correct
9 Correct 113 ms 348 KB Output is correct
10 Correct 121 ms 344 KB Output is correct
11 Execution timed out 3050 ms 624 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3085 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -