#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#define MAXN 100 + 100
int ans[MAXN];
int add[MAXN];
void input()
{
string str;
memset(ans, 0, sizeof(ans));
while (cin >> str)
{
if (str[0] == '0')
{
break;
}
int len = str.length();
for (int i = len - 1, j = 0; i >= 0; i--, j++)
{
add[j] = str[i] - '0';
}
for (int i = 0; i < MAXN; i++)
{
ans[i] = ans[i] + add[i];
if (ans[i] > 9)
{
ans[i] %= 10;
ans[i + 1]++;
}
}
}
int u = 0;
for (int i = MAXN - 1; i >= 0; i--)
{
if (ans[i] != 0)
{
u = i;
break;
}
}
for (int i = u; i >= 0; i--)
{
cout << ans[i];
}
cout << endl;
}
int main()
{
input();
return 0;
}
ACM-uva424
最新推荐文章于 2015-08-02 12:03:01 发布