제출 #406578

#제출 시각아이디문제언어결과실행 시간메모리
406578Ronin13Rack (eJOI19_rack)C++14
100 / 100
1 ms204 KiB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define INF 1e9+1;
using namespace std;
vector<ll>path;
void rec(ll x,ll lev){
    if(lev==0){path.pb(x);return;}
    if(x<=(1LL<<(lev-1)))rec(x,lev-1);
    else
    rec(x-(1LL<<(lev-1)),lev-1);
    path.pb(x);
}

ll mod=1e9+7;
ll logpow(ll a,ll pow){
    if(pow==0)return 1;
    ll k=logpow(a,pow/2);
    k*=k;k%=mod;
    if(pow&1)k*=(a%mod);
    return k%mod;
}

void solve(){
    ll n,k;cin>>n>>k;
    ll lev=log2(k);
    if((1LL<<lev)!=k)lev++;
    rec(k,lev);

    ll curhook=path[0];
    ll cur=n-1;
    for(int i=0;i<path.size()-1;i++){
        if(path[i]!=path[i+1]){
            curhook+=logpow(2,cur);
            curhook%=mod;
        }
        cur--;
    }
    cout<<curhook;
}
int main(){
    int t;t=1;
    while(t--){
        solve();
    }
}

컴파일 시 표준 에러 (stderr) 메시지

rack.cpp: In function 'void solve()':
rack.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0;i<path.size()-1;i++){
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...