이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <cmath>
#include <iterator>
#include <vector>
#define ff first
#define ss second
#define mp make_pair
#define ll long long
using namespace std;
int main() {
int n;
long long q, s = 0;
cin >> n >> q;
int modulo[n];
modulo[0] = 1;
for (int i = 1; i < n; i++){
modulo[i] = (modulo[i - 1] * 2) % 1000000007;
}
bool way = true;
for (int i = 0; i < n; i++){
if (way == true){
if (q % 2 == 0){
s = (modulo[n - i - 1] + s) % 1000000007;
} else {
way = false;
}
} else {
if (q % 2 == 1){
s = (modulo[n - i - 1] + s) % 1000000007;
}
}
q = q / 2;
}
s = (s + 1) % 1000000007;
cout << s << 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... |