/*
* UVA_10013.cpp
*
* Created on: 2013年10月29日
* Author: Administrator
*/
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int ans[1000005];
int main() {
int t;
scanf("%d", &t);
while (t--) {
memset(ans, 0, sizeof(ans));
int M;
scanf("%d", &M);
int j;
for (j = M - 1; j >= 0; --j) {//由高位到底为处理一遍
int num1, num2;
scanf("%d%d", &num1, &num2);
ans[j] += num1 + num2;
ans[j + 1] += ans[j] / 10;
ans[j] %= 10;
}
for(j = 0 ; j < M ;++j){//由地位到高位处理一遍
ans[j+1] += ans[j]/10;
ans[j] %= 10;
}
if (ans[M]) {//判断最高位是否有进位
M++;
}
for (j = M - 1; j >= 0; --j) {//由高位到低位输出结果
printf("%d", ans[j]);
}
printf("\n");
if (t > 0) {
printf("\n");
}
}
return 0;
}
分享到:
相关推荐
373._Find_K_Pairs_with_Smallest_Sums查找和最小的k对数字【LeetCode单题讲解系列】
Eclipse-plugins 插件,eclipse 各种插件 .jar 包,免费下载 eclipse202106 -plugins 各种插件 .jar 包,免费下载 如果下载不了,关注我,评论区联系我, Eclipse-plugins eclipse, plugins, eclipse202106, ...
0.1 Finite Sums ..................................... 1 0.11 Progressions .................................... 1 0.12 Sums of powers of natural numbers ........................ 1 0.13 Sums of ...
0.1 Finite Sums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0.11 Progressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 0.12 Sums of ...
SUMS48 Introduction to Analytical Dynamics, Revised Edition, Nicholas Woodhouse (2009).zip
The cows in farmer John's herd are numbered and branded with consecutive integers from 1 to N (1 <= N <= 10,000,000). When the cows come to the barn for milking, they always come in sequential order ...
Solutions Hole 5 (wc)..................................................................................................................................................................................24 ...
SUMS28 Further Linear Algebra, T. S. Blyth, E. F. Robertson (2002).djvu
SUMS28 Further Linear Algebra, T. S. Blyth, E. F. Robertson (2002).zip
Springer Undergraduate Mathematics Series(SUMS) SUMS20 Symmetries, D. L. Johnson (2001).pdf
Table of Contents Preface, Notes, Licenses . . . . . . . . ....1. Licenses for Third-Party Components ....1.1. FindGTest.cmake License ....1.2. LPeg Library License ....1.3. LuaFileSystem Library License ....
Springer Undergraduate Mathematics Series(SUMS)
checksums.lock
SUMS25 Basic Linear Algebra, 2nd Edition, T. S. Blyth, E. F. Robertson (2002).djvu
SUMS21 Geometry, Roger Fenn (2001).djvu
SUMS01 Groups, Rings and Fields, D. A. R. Wallace (1998) .zip
SUMS37 Hyperbolic Geometry, 2nd Edition, James W.Anderson (2005).zip
SUMS20 Symmetries, D. L. Johnson (2001).zip SUMS20 Symmetries, D. L. Johnson (2001).zip
北大POJ2602-Superlong sums 解题报告+AC代码
SUMS14 Information and Coding Theory, Gareth A. Jones, J. Mary Jones (2000) .zip