Submission #453240

#TimeUsernameProblemLanguageResultExecution timeMemory
453240myvaluskaRack (eJOI19_rack)C++14
100 / 100
118 ms288 KiB
#include <iostream> #include <vector> #include <string> #include <set> #include <cmath> #include <tuple> using namespace std; /*long long int power(long long int n, int k) { long long int vys = 1; for (int i = 0; i < k; i++) { vys = (vys * (n - i)) / (i + 1); } return vys; }*/ long long int power(long long int b, long long int p, long long int mod) { long long int vys = 1; for (long long int i = 0; i < p; i++) { vys = vys * b; vys %= mod; } return vys; } int main() { /*for (int i = 0; i < 10; i++) { std::cout << "Hello Flash!\n"; }*/ long long int n; long long int k; cin >> n; cin >> k; const long long int mod = 1e9 + 7; k -= 1; long long int i = n - 1; long long int vys = 1; while (i >= 0) { if (k % 2 !=0) { vys = (vys + power(2, i, mod)) % mod; } k = k / 2; i -= 1; } cout << vys % mod << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...