답안 #893813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893813 2023-12-27T13:33:38 Z Almonther Rack (eJOI19_rack) C++
100 / 100
6 ms 1532 KB
#include <bits/stdc++.h>

#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
#define ld long double
#define clo cout << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
#define co cout <<
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define unsit unsigned int
#define unsl unsigned long long
using namespace std;
//stuff
ll pw(ll a,ll b){
    if(b==0) return 1;
    ll hf=pw(a,b/2);
    if(b&1) return hf*hf*a;
    return hf*hf;
}
ll n,k;
void solve(){
    cin>>n>>k;
    ll a=1,b=pw(2,min(61,int(n)));
    ll save=k;
    ll cnt=n-1;
    while(save>b/2&&b>1){
        save-=b/2;
        b/=2;
        a*=2;
        cnt--;
    }
    string s="";
    b=2;
    ll pluss=0;
    for(int i=0;i<cnt;i++){
        s+=(k%b>b/2||k%b==0)?'1':'0';
        if(k%b==k){
            pluss=cnt-i;
            break;
        }
        b*=2;
    }
    for(int i=0;i<pluss-1;i++) s+='0';
    s+='1';
    ll ans=0;
    for(int i=0;i<s.size();i++){
        ans=(ans*2+(s[i]-'0'))%MOD;
    }
    co ans%MOD*a%MOD;
}
int main()
{
    suiii
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

rack.cpp: In function 'void solve()':
rack.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 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 344 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 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 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 344 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 452 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 6 ms 1532 KB Output is correct