이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll Mod = 1e9 + 7;
int n;
ll k;
string s;
ll pot[1000007];
ll m(ll x) {
return (x < Mod) ? x : x % Mod;
}
int main () {
cin >> n >> k;
for (int i = 0; i < n; i++) {
if (k & 1) {
s += '0';
}
else {
s += '1';
}
k = (k + 1) / 2;
}
int y = s.size();
pot[y-1] = 1;
for (int i = y-2; i >= 0; i--) {
pot[i] = m(pot[i+1] * 2);
}
ll res = 0;
for (int i = 0; i < y; i++) {
res = m(res + (s[i] - '0') * pot[i]);
}
cout << res+1;
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... |