文章

166

粉丝

68

获赞

825

访问

49.7k

头像
又一版 A+B 题解:注意有0,且题目有误,不是231-1,是2^31-1,需要long long
P1328 浙江大学机试题
发布于2025年3月18日 15:50
阅读数 77

#include <bits/stdc++.h>

using namespace std;
int main() {
    int m;
    while(cin>>m){
        if(m==0)break;
		long long a,b;
        cin>>a>>b;
        a+=b;
		if(a==0){
			cout<<0<<endl;
			continue;
		}
        string s;
        while(a!=0){
            s.push_back(a%m+'0');
            a/=m;
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发