| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 684199 | Tigerpants | Rack (eJOI19_rack) | C++17 | 2 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll mod = 1000000007;
vll po2;
ll pow2(ll x) {
if (x >= po2.size()) {
if (x & 1) {
po2[x] = (2 * pow2(x - 1)) % mod;
} else {
po2[x] = (pow2(x / 2) * pow2(x / 2)) % mod;
}
}
return po2[x];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, k;
cin >> n >> k;
k -= 1;
po2.push_back(1);
// for a structure with n levels, on which hook should the k'th coat hang
// consinder hanging coats one by one. for each rack, it alternates whether it should be hung to the left or right, always starting with the left
// so we check the bitrepresentation of k
// 0000, 1000, 0100, 1100, 0010, 1010, 0110, 1110, 0001, 1001, 0101, 1101, 0011, 1011, 0111, 1111
// so the answer is k reversed mod 2 ^ n...
ll answ = 0;
for (int i = 0; i < 63; i++) {
if ((k >> i) & 1) {
answ += pow2(n - 1 - i);
answ %= mod;
}
}
cout << answ + 1 << endl;
return 0;
}컴파일 시 표준 에러 (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... | ||||
