이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#define int long long
const int N = 1e9;
const int mod = N +7;
bool a[N + 5];
using namespace std;
int build(int b, int p) {
if(p == 1) {
return b;
}
if(p == 0) {
return 1;
}
if(p % 2 == 0) {
int tmp = build(b, p >> 1);
return tmp * tmp % mod;
}
else {
int tmp = build(b, (p - 1) >> 1);
return tmp * tmp % mod * b % mod;
}
}
int32_t main() {
int n;
int k;
int ans = 0;
cin >> n >> k;
k -= 1;
int j = n - 1;
while(k) {
a[j--] = k % 2;
k /= 2;
}
for(int i = 0; i < n; ++i){
if(a[i])
ans = (ans + build(2, i)) % mod;
}
ans += 1;
ans %= mod;
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |