比赛 20250409练习赛 评测结果 AAAAAAAAAA
题目名称 数列 最终得分 100
用户昵称 ChenBp 运行时间 0.030 s
代码语言 C++ 内存使用 3.57 MiB
提交时间 2025-04-09 19:45:32
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
ll pw(ll a,ll b){
    if(a==0)return 0;
    if(b==0)return 1;
    ll x=pw(a,b/2);
    if(b&1) return x*x*a;
    return x*x;
}
ll lowbit(ll x){
    return x&(-x);
}
int main(){
    freopen("sequenc.in","r",stdin);
    freopen("sequenc.out","w",stdout);
    int k,n;
    cin>>k>>n;
    ll ans=0;
    while(n){
        ans+=pow(k,log2(lowbit(n)));
        n-=lowbit(n);
    }
    cout<<ans;
    return 0;
}