답안 #794645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794645 2023-07-26T18:07:24 Z Ludissey Rack (eJOI19_rack) C++14
40 / 100
1 ms 300 KB
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <vector>
#include <fstream>
#include <bitset>
#include <tuple>
#include <cmath>
#include <cstdint>
#include <stack>
#include <cassert>
#include <cstdio>
#include <queue>
#include <iterator>
#include <iomanip>
#include <algorithm>
#include <sstream>

const int MOD = 1000000007;

using namespace std;

int n, k;

long long power(int x) {
	long long sum = 1;
	for (int i = 0; i < x; i++){ 
		sum = (sum*2) % MOD;
	}
	return sum;
}

long long  ceiling(int a, int b) {
	return (a + b + 1) / 2;
}

long long div(long long l, long long r, long long indx, long long mult) {
	if (r == l + 1) return l;
	int mid= ceiling(l ,r);
	if (indx % mult == 0) {
		return div(mid, r, indx, mult * 2);
	}
	else {
		return div(l, mid, indx+(mult/2), mult * 2);
	}
}

signed main() {
	cin >> n >> k;

	long long tot = power(n)%MOD;
	int extra = 0;
	if (k > tot / 2) {
		k -= (tot / 2);
		extra = 1;
	}
	long long ans = div(1, tot, k, 2) + extra;
	long long mod = ans % MOD;
	cout << mod << "\n";
	return 0;
}
//1000000 1000000000000000000
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -