题目1026:又一版 A+B
#include <stdio.h>
#include <iostream>
#include <stack>
#include <string.h>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long LL;
#define MAX 1000001
void fun(LL a, int m)
{
if(a == 0){
cout << "0" << endl;
return ;
}
stack<int> s1;
while(a != 0){
s1.push(a % m);
a /= m;
}
while(!s1.empty()){
cout << s1.top();
s1.pop();
}
cout << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
LL m, a, b;
while(scanf("%ld", &m) != EOF){
if(m == 0){
break;
}
scanf(" %ld %ld", &a, &b);
LL tem = a + b;
fun(tem, m);
//cout << fun(a, m) << endl;
}
return 0;
}
/**************************************************************
Problem: 1026
User: Crazy_man
Language: C++
Result: Accepted
Time:20 ms
Memory:24956 kb
****************************************************************/