답안 #1099077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099077 2024-10-10T13:17:36 Z vjudge1 Rack (eJOI19_rack) C++17
100 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9 + 7;

int binpow(int a, int b){
    if(!b) return 1;
    else if(b % 2 == 0){
        int x = binpow(a, b / 2);
        return (x * x) % MOD;
    }else{
        int x = binpow(a, b / 2);
        x = (x * x) % MOD;
        return (x * a) % MOD;
    }
}

signed main(){
    int n, k; cin >> n >> k;
    int cnt = 0;
    int ans = 1;
    int pp = binpow(2, n - 1) % MOD;

    
    while(k > 1){
        if (k % 2 == 0) {
            k--;
            
            ans += pp;
            ans %= MOD;
            
        }
        
        k -= (k - 1) / 2;
        
        pp = (pp * binpow(2, MOD - 2) % MOD) % MOD;
        pp %= MOD;
    }
    cout << ans << endl;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:21:9: warning: unused variable 'cnt' [-Wunused-variable]
   21 |     int cnt = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 1 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 1 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 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct