# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1015895 | tuannm | Rack (eJOI19_rack) | C++17 | 1 ms | 516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ii pair<int, int>
#define ll pair<long long, long long>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int mod[2] = {1000000007, 998244353};
const int N = 1e5 + 1;
const string NAME = "";
int n;
long long k;
void addSelf(int &a, int b){
a += b;
if(a >= mod[0])
a -= mod[0];
if(a < 0)
a += mod[0];
}
int add(int a, int b){
a += b;
if(a >= mod[0])
a -= mod[0];
if(a < 0)
a += mod[0];
return a;
}
int mul(int a, int b){
long long a1 = 1LL * a * b;
long long a2 = (a1 / mod[0]) * mod[0];
return a1 - a2;
}
void mulSelf(int &a, int b){
a = mul(a, b);
}
int binpow(int a, int b){
int ret = 1;
while(b){
if(b & 1)
mulSelf(ret, a);
mulSelf(a, a);
b >>= 1;
}
return ret;
}
void inp(){
cin >> n >> k;
}
void solve(){
int ans = 1;
for(int i = n - 1; i >= 0; --i){
if(k & 1)
k = k + 1 >> 1;
else{
addSelf(ans, binpow(2, i));
k >>= 1;
}
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen((NAME + ".inp").c_str(), "r")){
freopen((NAME + ".inp").c_str(), "r", stdin);
freopen((NAME + ".out").c_str(), "w", stdout);
}
inp();
solve();
}
컴파일 시 표준 에러 (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... |