답안 #577140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577140 2022-06-14T07:41:05 Z dozer Rack (eJOI19_rack) C++14
40 / 100
1 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
#define L(node) node * 2
#define R(node) node * 2 + 1
#define int long long

const int modulo = 1e9 + 7; 
int n;


int fe(int a, int b)
{
	if (b == 0) return 1;
	if (b % 2 == 1) return (b * fe(a, b - 1)) % modulo;
	int tmp = fe(a, b / 2);
	return (tmp * tmp) % modulo;
}

int f(int k, int level)
{
	if (level > n) return 1;
	if (k == 1) return 1;
	int odd = 0;
	if (k % ((long long)1<<level) == 1) odd = 1;
	if (odd) return f(k, level + 1);
	return (f(k - ((long long)1<<(level - 1)), level + 1) + ((long long)1<<(n - level))) % modulo;
}

int32_t main()
{
	//fileio();
	fastio();

	int k;
	cin>>n>>k;
	cout<<f(k, 1)<<endl;

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -