답안 #893840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893840 2023-12-27T14:17:46 Z Essa2006 Rack (eJOI19_rack) C++14
100 / 100
12 ms 4188 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)

int add(ll a, ll b) {
    ll res = a + b;
    return res % mod;
}

int mul(ll a, ll b) {
    a %= mod, b %= mod;
    ll res = a * b;
    return res % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    
    vector<int> Pwr_of_two(n+1);
    Pwr_of_two.front() = 1;
    for (int i = 1; i <= n; i++) {
        Pwr_of_two[i] = mul(Pwr_of_two[i - 1], 2);
    }
    
    ll ans = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (k % 2 == 0) {
            ans = add(ans, Pwr_of_two[i]);
        }
        k = (k + 1) / 2;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 1 ms 856 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 460 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 12 ms 4188 KB Output is correct