This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define sz(x) (int)x.size()
#define speed ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<long long, long long>>
#define fl fflush(stdout)
const ll INF = INT_MAX;
const int N = (int)1e5 + 20;
const ll mod = (ll)1e9 + 7;
const int P = 31;
ll binpow(ll a, int n){if(n == 0)return 1;if(n == 1)return a;ll r = binpow(a, n / 2) % mod;if(n % 2)return (((r * r) % mod) * a) % mod;return(r * r) % mod;}
void setIO() {
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
bool ans[10 * N];
void yela(){
ll n, k;
cin >> n >> k;
k--;
for(int i = 0; i < n; i++){
ans[i] = k & (binpow(2, i));
}
reverse(ans, ans + n);
ll sum = 0;
for(int i = 0; i<n; i++){
if(ans[i]){
sum += binpow(2, i);
sum %= mod;
}
}
cout << sum + 1;
}
int main(){
speed;
int T = 1;
//cin >> T;
for(int i = 1; i <= T; i++){
yela();
}
}
Compilation message (stderr)
rack.cpp: In function 'void setIO()':
rack.cpp:29:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | freopen("in.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
rack.cpp:30:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | freopen("out.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |