#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <cmath>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 100005;
const int INF = 0x3f3f3f3f;
#define reg register
#define IOS ios::sync_with_stdio(false)
stack<int> s;
ll k, n, ans;
int main() {
cin >> k >> n;
while(n){
s.push(n&1);
n>>=1;
}
while(!s.empty()){
ans+=s.top()*pow(k,s.size()-1);
s.pop();
}
printf("%lld",ans);
return 0;
}
P1062 [NOIP2006 普及组] 数列(进制)
最新推荐文章于 2024-05-30 20:15:33 发布