This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
using namespace std;
typedef long long ll;
ll power[1000007];
int main(){
ll n, k;
cin >> n >> k;
power[0] = 1;
for(int i = 1; i <= n; i++)
power[i] = (power[i - 1] * 2) % (ll)(1e9 + 7 );
ll add = n-1;
ll ans = 0, step = n-1;
while(step > 0){
if(k % 2 == 0){
ans += power[add];
ans %= (ll)(1e9 + 7);
}
k = (k + 1) / 2;
step--;
add--;
}
ans += k;
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |