1 条题解

  • 2
    @ 2022-10-2 18:05:04
    #include <iostream>
    #include <stack>
    #include <cmath>
    using namespace std;
    
    long long k, n, ans;
    stack<int> S;
    
    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();
        cout << ans << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    63
    时间
    1000ms
    内存
    125MiB
    难度
    2
    标签
    递交数
    8
    已通过
    7
    上传者