結果

問題 No.916 Encounter On A Tree
ユーザー ttttan2ttttan2
提出日時 2019-10-25 22:40:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,883 bytes
コンパイル時間 1,408 ms
コンパイル使用メモリ 146,252 KB
実行使用メモリ 24,044 KB
最終ジャッジ日時 2023-10-11 06:19:11
合計ジャッジ時間 5,472 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 45 ms
23,788 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 44 ms
23,848 KB
testcase_06 WA -
testcase_07 AC 44 ms
23,844 KB
testcase_08 AC 44 ms
23,892 KB
testcase_09 AC 45 ms
23,796 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 44 ms
23,844 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 44 ms
23,820 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 44 ms
23,776 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 WA -
testcase_18 AC 44 ms
23,816 KB
testcase_19 AC 44 ms
23,800 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 44 ms
23,788 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 44 ms
23,800 KB
testcase_28 AC 2 ms
4,356 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 1 ms
4,352 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 45 ms
23,804 KB
testcase_35 AC 44 ms
23,936 KB
testcase_36 AC 44 ms
23,860 KB
testcase_37 AC 44 ms
23,868 KB
testcase_38 WA -
testcase_39 AC 1 ms
4,352 KB
testcase_40 AC 44 ms
23,816 KB
testcase_41 AC 44 ms
23,888 KB
testcase_42 AC 44 ms
23,928 KB
testcase_43 AC 44 ms
23,792 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 44 ms
23,792 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 44 ms
23,796 KB
testcase_48 AC 1 ms
4,352 KB
testcase_49 AC 44 ms
23,776 KB
testcase_50 AC 44 ms
23,788 KB
testcase_51 AC 44 ms
23,800 KB
testcase_52 WA -
testcase_53 AC 44 ms
23,912 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 44 ms
23,828 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 44 ms
23,844 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:55:12: warning: ‘der’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     while(k>0){
           ~^~
main.cpp:104:12: note: ‘der’ was declared here
     ll del,der;
            ^~~
main.cpp:143:26: warning: ‘del’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         ll ans=beki(2,k/2+del-1);
                       ~~~^~~~

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

ll gya[2500010];
ll kai[2500010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll d,l,r,k;cin>>d>>l>>r>>k;
    ll del,der;
    ll now=1;
    rep(i,0,30){
        now*=2;
        if(now>l){
            del=i;
            break;
        }
    }
    ll noww=1;
    rep(i,0,30){
        noww*=2;
        if(noww>r){
            der=i;
            break;
        }
    }
    if(del+der<k){
        cout<<0<<endl;
        return 0;
    }
    if((del+der)%2!=k%2){
        cout<<0<<endl;
        return 0;
    }
    nckinit(1100000);
  // cout<<del<<" "<<der<<endl;
    if(del!=der){
        ll ans=beki(2,der);
        rep(i,0,d){
            ll y=Pow(2,i);
            if(i==del||i==der)y--;
            ll yy=kai[y];
            ans*=yy;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
    else{
        ll ans=beki(2,k/2+del-1);
        rep(i,0,d){
            ll y=Pow(2,i);
            if(i==del)y-=2;
            ll yy=kai[y];
            ans*=yy;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
}
0