Files
python/TangDou/CSP-J/AcWingTraining/T6/me.cpp

16 lines
329 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
long long get(int a,int b){
long long res=1;
while(b--)res*=a;
return res;
}
int main() {
int n, k;
cin>>k>>n;
long long res = 0;
for (int i = 0; i < 20;i++)
if (n >> i & 1) res += get(k, i);
cout << res << endl;
return 0;
}