답안 #675664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675664 2022-12-27T16:58:50 Z a_aguilo Rack (eJOI19_rack) C++14
40 / 100
1 ms 212 KB
#include<bits/stdc++.h>

using namespace std;

unordered_map<long long, long long> powers;
const int MOD = 1e9+7;

long long int PowerTwo(int exponent){
    if(powers.find(exponent) != powers.end()) return powers[exponent];
    long long semiAns = PowerTwo(exponent/2);
    long long ans = (semiAns*semiAns)%MOD;
    if(exponent%2) {
        ans*= 2;
        ans%=MOD;
    }
    return powers[exponent] = ans;
}

long long getPos(int n, int k){
    if(k == 1) return 1;
    if(k%2){
        return getPos(n-1, k/2 +1);
    }
    else{
        long long semiAns = PowerTwo(n-1);
        long long ans = (semiAns + getPos(n-1, k/2))%MOD;
        return ans;
    }
}

int main(){
    powers[0] = 1;
    powers[1] = 2;
    powers[2] = 4;
    int n, k;
    cin >> n >> k;
    cout << getPos(n, k)<< endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -