# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
467184 | nemethm | Rack (eJOI19_rack) | C++17 | 1 ms | 204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <list>
#include <algorithm>
#include <queue>
#include <vector>
#include <limits>
#include <set>
#include <numeric>
#include <string>
#include <assert.h>
#include <map>
#include <cmath>
#include <stack>
#include <cstring>
#include <stack>
#pragma warning(disable : 4996)
using namespace std;
using ll = long long int;
const ll inf = numeric_limits<ll>::max();
//const ll mod = 1e9+7;
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
uint64_t binpow(uint64_t base, uint64_t exp, uint64_t mod) {
if (exp == 0) return 1;
uint64_t half = binpow(base, exp / 2, mod);
uint64_t answ = (half * half) % mod;
if (exp % 2 == 1) {
answ *= base;
answ %= mod;
}
return answ;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(9);
uint64_t n, k, m = 1e9 + 7;
cin >> n >> k;
--k;
uint64_t k_rev = 0;
for (int i = 0; i < 64; ++i) {
if ((k >> i) & 1) k_rev |= 1ull << (64 - i - 1);
}
if (n <= 64) {
k_rev >>= (64 - n);
k_rev %= m;
++k_rev;
k_rev %= m;
cout << k_rev << endl;
}
else {
uint64_t twopower = binpow(2, n - 64, m);
uint64_t answ = 0;
for (int i = 0; i < 64; ++i) {
if ((k_rev >> i) & 1) {
answ += twopower;
answ %= m;
}
twopower *= 2;
twopower %= m;
}
++answ;
answ %= m;
cout << answ << 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... |