제출 #216711

#제출 시각아이디문제언어결과실행 시간메모리
216711MODDIRack (eJOI19_rack)C++14
100 / 100
17 ms8684 KiB
#include <bits/stdc++.h> using namespace std; int MOD= 1e9 + 7; int main() { long long n, k; cin>>n>>k; vector<long long> pow_two; pow_two.push_back(1); long long at=1; for(int i=1;i<n;i++) { at*=2; at %= MOD; if(at < 0) return 0; pow_two.push_back(at); } long long rez=1; long long step=1; while(k!=1) { if(k%2==0) { rez+=pow_two[n-step]; rez %= MOD; if(rez < 0) return 0; k-=k/2; step++; } else { step++; k-=k/2; } } cout<<rez<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...