답안 #237604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237604 2020-06-07T17:33:29 Z Pbezz Rack (eJOI19_rack) C++14
40 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAXN 100005
typedef pair<int, int> pii;

ll fast(ll base, ll exp){

ll res=1;
	while(exp>0){

	if(exp%2==1){

	exp--; res*=base;
	res%=MOD;
	base%=MOD;

	}
	if(exp==0)break;

	base*=base; base%=MOD;
	exp/=2;

	}

	return res;

}

ll solve(ll n, ll k){

	if(n==1&&k==1)return 1;
	if(n==1&&k==2)return 2;

	ll ans = fast(2,n-1);

	if(k%2==0)return solve(n-1,k/2)+ans;
	else return solve(n-1,(k+1)/2);


}


int main(){

	ll n,k,ans;
	cin>>n>>k;

	ans=solve(n,k);
	cout<<ans<<'\n';

return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Incorrect 4 ms 256 KB Output isn't correct
12 Halted 0 ms 0 KB -