답안 #966583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
966583 2024-04-20T05:20:13 Z manizare Party (INOI20_party) C++14
0 / 100
3000 ms 712 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 (po(2 , 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){
                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 ;
}
/*


*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3043 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 290 ms 712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3059 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3043 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -