Submission #1094019

#TimeUsernameProblemLanguageResultExecution timeMemory
1094019MrNanamaRack (eJOI19_rack)C++17
100 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; using ll = long long; const ll MOD = (1000000007); template <typename T> ostream& operator<<(ostream& os, const vector<T>& vec){for (auto itr : vec){os << itr << " ";} return os;} ll n,k; ll ans; ll fpow(ll b, ll p){ if(b == 0){return 0;} if(p == 0){return 1;} if(p == 1){return b;} ll a = fpow(b, p/2)%MOD; a = (a*a)%MOD; if(p%2){a = (a*b)%MOD;} return a%MOD; } void solve(){ cin >> n >> k; ans = 0; k--; for(ll p=0; p<62; p++){ if((k>>p)&1){ ans = (ans+ fpow(2,n-p-1))%MOD; } } cout << ans+1 << endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...