Submission #464353

# Submission time Handle Problem Language Result Execution time Memory
464353 2021-08-13T05:28:31 Z amunduzbaev Rack (eJOI19_rack) C++14
40 / 100
1 ms 204 KB
#include "bits/stdc++.h"
using namespace std;

const int mod = 1e9+7;
int pw(int a, int b){
	int rr = 1;
	while(b){
		if(b&1) rr = rr * 1ll * a % mod;
		a = a * 1ll * a % mod, b >>= 1;
	} return rr;
}

void solve(){
	int n, k; cin>>n>>k;
	vector<int> bit(n);
	for(int i=0;i<(int)bit.size();i++){
		n--;
		if(n > 63){
			bit[i] = 0;
		} else {
			if(k <= (1ll << n)) bit[i] = 0;
			else bit[i] = 1, k -= (1ll << n);
		}
	}
	
	//~ for(int i=0;i<(int)bit.size();i++) cout<<bit[i]<<" ";
	//~ cout<<"\n";
	
	int res = 1;
	for(int i=0;i<(int)bit.size();i++){
		if(bit[i]) res = (res + pw(2, i)) % mod;
	} 
	
	cout<<res<<"\n";
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t = 1;
	//~ cin>>t;
	while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -