답안 #840856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840856 2023-08-31T18:57:12 Z raul2008487 Rack (eJOI19_rack) C++17
100 / 100
8 ms 7928 KB
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define vl vector<ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
using namespace std;
const int sz = 2e6+5;
const ll inf = 100000000000000005;
const int mod = 1e9+7;
ll tp[sz];
ll rec(ll k, ll n){
    if(n==0){
        return k;
    }
    ll lc = k/2 + k%2;
    ll rc = k/2;
    if(lc == rc){
        return (tp[n-1] + rec(rc, n-1))%mod;
    }
    return rec(lc,n-1);
}
void solve(){
    ll n,k,i,j;
    cin>>n>>k;
    tp[0] = 1;
    for(i=1;i<=n;i++){
        tp[i] = tp[i-1] * 2;
        tp[i] %= mod;
    }
    cout << rec(k, n) << endl;
}

int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Compilation message

rack.cpp: In function 'void solve()':
rack.cpp:26:14: warning: unused variable 'j' [-Wunused-variable]
   26 |     ll n,k,i,j;
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 8 ms 7928 KB Output is correct