You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
644 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
/*
离散化的思想。映射到2进制不会改变任何一位的顺序
因为k>3 题意那些k进制表达的数严格单调就像1100 >1011 每位都是排好顺序),
然后看它二进制表示中每一位是1还是0然后再逆映射回十进制.
*/
LL get(int a, int b) {
LL res = 1;
while (b--) res *= a;
return res;
}
int main() {
int n, k;
cin >> k >> n;
LL res = 0;
for (int i = 0; i < 20; i++)
if (n >> i & 1)
res += get(k, i);
cout << res << endl;
return 0;
}