답안 #307579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307579 2020-09-28T16:49:16 Z Mounir Rack (eJOI19_rack) C++14
100 / 100
14 ms 8192 KB
#include <bits/stdc++.h>
#define int long long
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define all(v) v.begin(), v.end()
using namespace std;

const int MOD = 1e9 + 7, N = 1e6 + 5;
int puissance[N];

signed main(){
	puissance[0] = 1;
	for (int expo = 1; expo < N; ++expo) puissance[expo] = (puissance[expo - 1] * 2)%MOD;
	
	int nBits, val, sum = 1;
	cin >> nBits >> val;
	val--;
	
	for (int iBit = 0; iBit < nBits; ++iBit){
		if (val%2 == 1) sum = (sum + puissance[nBits - 1 - iBit])%MOD;
		val /= 2;
	}
	cout << (sum + MOD)%MOD<< endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8192 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 12 ms 8192 KB Output is correct
5 Correct 12 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8192 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 12 ms 8192 KB Output is correct
5 Correct 12 ms 8192 KB Output is correct
6 Correct 11 ms 8192 KB Output is correct
7 Correct 11 ms 8192 KB Output is correct
8 Correct 11 ms 8192 KB Output is correct
9 Correct 11 ms 8192 KB Output is correct
10 Correct 13 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8192 KB Output is correct
2 Correct 11 ms 8192 KB Output is correct
3 Correct 11 ms 8192 KB Output is correct
4 Correct 12 ms 8192 KB Output is correct
5 Correct 12 ms 8192 KB Output is correct
6 Correct 11 ms 8192 KB Output is correct
7 Correct 11 ms 8192 KB Output is correct
8 Correct 11 ms 8192 KB Output is correct
9 Correct 11 ms 8192 KB Output is correct
10 Correct 13 ms 8192 KB Output is correct
11 Correct 11 ms 8192 KB Output is correct
12 Correct 11 ms 8192 KB Output is correct
13 Correct 11 ms 8192 KB Output is correct
14 Correct 11 ms 8192 KB Output is correct
15 Correct 14 ms 8192 KB Output is correct