Submission #453240

# Submission time Handle Problem Language Result Execution time Memory
453240 2021-08-04T09:51:24 Z myvaluska Rack (eJOI19_rack) C++14
100 / 100
118 ms 288 KB
#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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 9 ms 288 KB Output is correct
15 Correct 118 ms 268 KB Output is correct