답안 #1050835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050835 2024-08-09T15:08:08 Z ThommyDB Rack (eJOI19_rack) C++17
40 / 100
0 ms 504 KB
#include<bits/stdc++.h>

using namespace std;

const int mod = 10e9+7;

int n, k;

signed main(){
    cin >> n >> k;

    vector<int> layers(n);

    layers[0]=1;
    signed long long s = 1;
    
    for(int i = 1; i < n; i++){
        s*=2;
        s%=mod;
        layers[i] = s;
    }

    long long ans = 1;
    for(int i = 0; i < n; i++){
        if(k%2==0){//right
            k /=2;
            ans += layers[n-i-1];
            ans%=mod;
        }
        else{//left
            k++;
            k /= 2;
        }
    }

    cout << ans << "\n";
}

Compilation message

rack.cpp:5:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000007e+10' to '2147483647' [-Woverflow]
    5 | const int mod = 10e9+7;
      |                 ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 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 348 KB Output is correct
6 Correct 0 ms 348 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 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 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 348 KB Output is correct
6 Correct 0 ms 348 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 504 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -