답안 #779550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
779550 2023-07-11T14:14:21 Z vmanz Rack (eJOI19_rack) C++14
100 / 100
1 ms 300 KB
#include <iostream>

using namespace std;

const int MOD = 1e9 + 7;

int putere(int n)
{
    long long a = 2;
    int p = 1;
    while (n != 0)
    {
        if (n % 2 != 0)
        {
            p = (long long)p * a % MOD;
        }
        a = (long long)a * a % MOD;
        n /= 2;
    }
    return p;
}

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    k--;
    int rez = 0;
    long long p2 = 1;
    int e2 = 0;
    while (p2 <= k)
    {
        if (k & p2)
        {
            rez += putere(n - 1 - e2);
            rez %= MOD;
        }
        p2 += p2;
        e2++;
    }
    rez = (rez + 1) % MOD;
    cout << rez;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct