이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#define ll long long
#define pb push_back
#define F first
#define S second
#define ull unsigned long long
#define pii pair < int, int >
#define ld long double
using namespace std;
using namespace __gnu_pbds;
mt19937 gen(time(0));
template <typename T>
using ordered_set=tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 100000 * 5;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#else
#endif
ll n, k;
cin >> n >> k;
k--;
vector < ll > p;
for (int i = n - 1; i >= 1; i--) p.pb((1ll << i));
ll ans = 1;
for (int i = 0; i < p.size(); i++)
{
ll kol = k / (1ll << i);
ll ost = k % (1ll << i);
if (kol % 2 == 1 && k > 0)
ans += p[i];
else
if (kol % 2 == 0 && k == 0)
ans += p[i];
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
rack.cpp: In function 'int32_t main()':
rack.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for (int i = 0; i < p.size(); i++)
| ~~^~~~~~~~~~
rack.cpp:53:12: warning: unused variable 'ost' [-Wunused-variable]
53 | ll ost = k % (1ll << i);
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |