제출 #587355

#제출 시각아이디문제언어결과실행 시간메모리
587355Markomafko972Rack (eJOI19_rack)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const ll Mod = 1e9 + 7;

int n;
ll k;
string s;
ll pot[1000007];

ll m(ll x) {
	return (x < Mod) ? x : x % Mod;
}

int main () {
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) {
		if (k & 1) {
			s += '0';
		}
		else {
			s += '1';
		}
		k = (k + 1) / 2;
	}
	
	int y = s.size();
	
	pot[y-1] = 1;
	
	for (int i = y-2; i >= 0; i--) {
		pot[i] = m(pot[i+1] * 2);
	}
	
	ll res;
	
	for (int i = 0; i < y; i++) {
		res = m(res + (s[i] - '0') * pot[i]);
	}
	
	cout << res+1;
	
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

rack.cpp: In function 'int main()':
rack.cpp:45:14: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |  cout << res+1;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...