제출 #1305879

#제출 시각아이디문제언어결과실행 시간메모리
1305879NewtonabcRack (eJOI19_rack)C++20
40 / 100
1 ms576 KiB
#include<bits/stdc++.h> #define ll long long const ll MOD=1e9+7; using namespace std; ll mpow(int p){ ll ret=1,mult=2; if(p>60) return LLONG_MAX; while(p){ if(p&1) ret=(ret*mult)%MOD; p>>=1; mult=(mult*mult)%MOD; } return ret; } int cb(ll x){ int ret=0; while(x) ret++,x>>=1; return ret; } int main(){ ll n,k; cin>>n >>k; ll ret=0; if(cb(k)==n && (1<<n)==k){ cout<<mpow(n); return 0; } k--; for(int i=0;i<n;i++){ int po=n-i-1; //cout<<(1<<po) <<" "; bool fir; if(po>60 || k<(1LL<<po)) fir=1; else fir=0,k-=(1LL<<po); //cout<<fir <<" " ; if(fir==0) ret+=mpow(i); ret%=MOD; } cout<<ret+1LL; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...