이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
ll n, k;
int pot[1000005];
int add(int x, int y) {
if (x+y < MOD) return x+y;
return x+y-MOD;
}
int main () {
cin >> n >> k;
pot[0] = 1;
for (int i = 1; i <= n; i++) {
pot[i] = pot[i-1] * 2;
pot[i] %= MOD;
}
k--;
int br = 1;
for (int i = n-1; i >= 0; i--) {
if (k % 2 == 1) {
br = add(br, pot[i]);
}
k /= 2;
}
cout << br;
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... |