답안 #840852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840852 2023-08-31T18:48:26 Z raul2008487 Rack (eJOI19_rack) C++17
40 / 100
1 ms 292 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 = 2e5+5;
const ll inf = 100000000000000005;
const int mod = 1e9+7;
void solve(){
    ll n,k,i,j,low,high,mid,level=1, res=1, x=1;
    cin>>n>>k;
    if(n > 59){
        while(n>60){
            x*=2;
            x%=mod;
            n--;
        }
        low = 1, high = (1<<60);
    }
    else{
        low = 1, high = (1<<n);
    }
    while(low <= high){
        mid = (low+high) >> 1;
        if(low == high){
            cout << res << endl;
            return ;
        }
        if(k <= mid){
            high = mid;
        }
        else{
            low = mid+1;
            ll ad = (1<<level-1);
            ad%=mod;
            ad*=x;
            ad%=mod;
            res += ad;
            res%=mod;
        }
        level++;
    }
    cout << res << endl;
}

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

Compilation message

rack.cpp: In function 'void solve()':
rack.cpp:22:27: warning: left shift count >= width of type [-Wshift-count-overflow]
   22 |         low = 1, high = (1<<60);
      |                          ~^~~~
rack.cpp:38:30: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   38 |             ll ad = (1<<level-1);
      |                         ~~~~~^~
rack.cpp:14:12: warning: unused variable 'i' [-Wunused-variable]
   14 |     ll n,k,i,j,low,high,mid,level=1, res=1, x=1;
      |            ^
rack.cpp:14:14: warning: unused variable 'j' [-Wunused-variable]
   14 |     ll n,k,i,j,low,high,mid,level=1, res=1, x=1;
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 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 292 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -