답안 #1097531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097531 2024-10-07T14:37:36 Z vjudge1 Rack (eJOI19_rack) C++17
40 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;

const int MOD=1e9+7;

int n;
vll pw;

ll solve(int lvl, ll cnt){
    if(lvl==n||cnt==1) return cnt;
    if(cnt%2==1){
        return solve(lvl+1,(cnt+1)/2);
    }else{
        return pw[n-1-lvl]+solve(lvl+1,cnt/2)%MOD;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	
    ll k;
    cin>>n>>k;
    pw.resize(n+1);
    pw[0]=1;
    forn(i,n) pw[i+1]=pw[i]*2LL%MOD;
    cout<<solve(0,k)<<'\n';
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
2 Correct 1 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 1 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -