답안 #601182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601182 2022-07-21T12:46:40 Z Fidan Rack (eJOI19_rack) C++17
100 / 100
17 ms 15540 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=(2e5)+10;
const ll num=(1e9)+7;

vector<ll> p(60, 1);
void power(){
	for(ll i=1; i<60; i++){
		p[i]=p[i-1]*2;
	}
}

ll solve(ll n, ll k){
	if(k==1) return 1;
	if(n==1) return k;
	if(n>=61){
		return (2*solve(n-1, k)-1)%num;
	}
	else{
		if(k>p[n-1]){
			return (2*solve(n-1, k-p[n-1]))%num;
		}
		else{
			return (2*solve(n-1, k)-1)%num;
		}
	}
}
		
int main(){
	ll n, k;
	cin>>n>>k;
	power();
	cout<<solve(n, k);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 292 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 17 ms 15540 KB Output is correct