제출 #1198588

#제출 시각아이디문제언어결과실행 시간메모리
1198588SzymonKrzywdaRack (eJOI19_rack)C++20
100 / 100
0 ms328 KiB
#include <iostream> using ll =long long; using namespace std; const ll MOD = 1e9 + 7; ll fastP(ll a, ll p){ if (p == 0) return 1; if (p % 2 == 0){ ll w = fastP(a, p / 2); return (w * w) % MOD; } else{ return (fastP(a, p - 1) * a) % MOD; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n, k; cin >> n >> k; k--; ll wynik = 0; for (ll i = 63; i >= 0; i--){ if (k & (1LL << i)){ //cout << k << ' ' << i << ' ' << (1LL << i) << ' ' << (n - i - 1) << ' ' << fastP(2, (n - i - 1)) << '\n'; wynik += fastP(2, (n - i - 1)); wynik %= MOD; } } //1 0 0 1 0 cout << (wynik + 1) % MOD << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...