답안 #1099998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099998 2024-10-12T11:03:34 Z vjudge1 Rack (eJOI19_rack) C++17
0 / 100
1 ms 348 KB
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define PLL pair<ll, ll>
#define PB push_back
#define F first
#define S second
#define MP make_pair
const ll INF = 999999999999999999;
const ll M = 1000000000+7;

ll binExp(ll a, ll b){
    if(a==1){
        return 1;
    }
    if(b==0){
        return 1;
    }
    ll ans = 1;
    if(b%2==1){
        ans = a;
    }
    return (binExp((a*a)%M,b/2)*ans)%M;
}

int main(){
    ll n,k;
    cin>>n>>k;
    ll index = 1,npow = 1,tpow = 1, m = binExp(2,n),Inv = binExp(2,M-2);
    k--;
    for(ll i=0; i<=n; i++){
        if(npow>k or npow<1){
            break;
        }
        //cout<<(k&tpow)<<" "<<tpow<<endl;
        if((k&npow)!=0){
            //cout<<(m/tpow)/2<<endl;
            index = (index + (Inv*(m*tpow)%M)%M)%M;
        }
        tpow = (tpow*Inv)%M;
        npow*=2;
    }
    cout<<index<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -