题解 | #又一版 A+B#

又一版 A+B

https://www.nowcoder.com/practice/9255c05d45b8406c9b588d7c57aa920b

#include <bits/stdc++.h>
using namespace std;

void func(int m,long x){
    vector<int>v;
    while(x!=0){
        v.push_back(x%m);
        x/=m;
    }
    for(auto it = v.rbegin();it!=v.rend();it++)
        cout<<*it;
    cout<<endl;
}

int main() {
    long m,a,b;
    while(cin>>m>>a>>b){
        if(a+b == 0)cout<<0<<endl;
        else func(m,a+b);
    }
}
// 64 位输出请用 printf("%lld")

int会溢出

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务