luogu_1062 数列

#include <cstdio>
#include <iostream>
using namespace std;
long long k,n,ans;

int main(){
    scanf("%lld%lld",&k,&n);
    long long x=1;
    while(n){
        if(n&1)ans+=x;
        x*=k;
        n>>=1;
    }
    printf("%lld\n",ans);
    return 0;
}

  

posted @ 2017-10-11 18:05  wqtnb_tql_qwq_%%%  阅读(120)  评论(0编辑  收藏  举报