# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
469567 |
2021-09-01T11:04:52 Z |
FatihSolak |
Rack (eJOI19_rack) |
C++17 |
|
6 ms |
8140 KB |
#include <bits/stdc++.h>
#define N 1000005
#define int long long
using namespace std;
const int mod = 1e9+7;
int pw[N];
int binpow(int a,int b){
int ret = 1;
while(b){
if(b&1){
ret = ret*a%mod;
}
a = a*a%mod;
b >>= 1;
}
return ret;
}
void solve(){
int n,k;
cin >> n >> k;
int ans = 1;
for(int i=60;i>=0;i--){
if(k > pw[i]){
k -= pw[i];
ans = (ans + binpow(2,n-i-1))%mod;
}
}
cout << ans;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
pw[0] = 1;
for(int i=1;i<N;i++){
pw[i] = min((int)2e18,pw[i-1]*2);
}
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8140 KB |
Output is correct |
2 |
Correct |
5 ms |
8060 KB |
Output is correct |
3 |
Correct |
5 ms |
8012 KB |
Output is correct |
4 |
Correct |
5 ms |
8012 KB |
Output is correct |
5 |
Correct |
5 ms |
8012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8140 KB |
Output is correct |
2 |
Correct |
5 ms |
8060 KB |
Output is correct |
3 |
Correct |
5 ms |
8012 KB |
Output is correct |
4 |
Correct |
5 ms |
8012 KB |
Output is correct |
5 |
Correct |
5 ms |
8012 KB |
Output is correct |
6 |
Correct |
5 ms |
8140 KB |
Output is correct |
7 |
Correct |
5 ms |
8012 KB |
Output is correct |
8 |
Correct |
5 ms |
8012 KB |
Output is correct |
9 |
Correct |
5 ms |
8012 KB |
Output is correct |
10 |
Correct |
6 ms |
8012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8140 KB |
Output is correct |
2 |
Correct |
5 ms |
8060 KB |
Output is correct |
3 |
Correct |
5 ms |
8012 KB |
Output is correct |
4 |
Correct |
5 ms |
8012 KB |
Output is correct |
5 |
Correct |
5 ms |
8012 KB |
Output is correct |
6 |
Correct |
5 ms |
8140 KB |
Output is correct |
7 |
Correct |
5 ms |
8012 KB |
Output is correct |
8 |
Correct |
5 ms |
8012 KB |
Output is correct |
9 |
Correct |
5 ms |
8012 KB |
Output is correct |
10 |
Correct |
6 ms |
8012 KB |
Output is correct |
11 |
Correct |
5 ms |
8012 KB |
Output is correct |
12 |
Correct |
5 ms |
8012 KB |
Output is correct |
13 |
Correct |
6 ms |
8076 KB |
Output is correct |
14 |
Correct |
5 ms |
8012 KB |
Output is correct |
15 |
Correct |
5 ms |
8012 KB |
Output is correct |