Trang

Chủ Nhật, 2 tháng 1, 2011

3496. Summation

import java.io.*;

public class Main {

    /**
     * http://acm.tju.edu.cn/toj/showp3496.html
     * @author hunglee
     */
    public static void main(String[] args) throws IOException {
        
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(
                new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        
        int n, x, y, a, b;
        in.nextToken();
        n = (int) in.nval;
        while (n-- > 0) {
            in.nextToken();
            x = (int) in.nval;
            in.nextToken();
            y = (int) in.nval;
            a = b = 0;
            while (x > 0) {
                a = (a << 3) + (a << 1) + x % 10;
                x /= 10;
            }
            while (y > 0) {
                b = (b << 3) + (b << 1) + y % 10;
                y /= 10;
            }
            out.println((a + b) + "\n");
        }
        out.flush();
    }

}

Không có nhận xét nào:

Đăng nhận xét