# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1260444 | mingga | Rack (eJOI19_rack) | C++20 | 0 ms | 328 KiB |
// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 1e6 + 7;
int n, k, p[N];
int add(int x, int y) {
x += y;
if(x >= mod) x -= mod;
return x;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> k;
p[0] = 1;
for(int i = 1; i <= n; i++) p[i] = add(p[i - 1], p[i - 1]);
int st = 1;
if(n - 1 <= 62 and (1ll << (n - 1)) < k) {
k -= (1ll << (n - 1));
st = 2;
}
if(k == 1) {
cout << st;
return 0;
}
k--;
for(int i = 0; i <= n; i++) {
if(k >> i & 1) {
st = add(st, p[n - i - 1]);
}
}
// cerr << 64 << ' ' << (1ll << 63) + 1 << ln;
cout << st;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |