杭电HDOJ--ACM1002(JAVA解题,运用BigInteger)

JAVA解题:

import java.util.*;

import java.io.*;
import java.math.BigInteger;

public class Main{

    public static void main(String[] arg){
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int n = scan.nextInt();
        int l = n;
        while(n--!=0){
            BigInteger integer = new BigInteger(scan.next());
            BigInteger integer2 = new BigInteger(scan.next());
            System.out.println("Case " + (l-n+1) + ":");
            System.out.println(integer + " + " + integer2  +  " = " +integer.add(integer2));
            if(n!=1){
                System.out.println();
            }
        }    scan.close();
    }
}
时间: 2024-10-13 14:05:22

杭电HDOJ--ACM1002(JAVA解题,运用BigInteger)的相关文章

杭电1047(Integer Inquiry)java水过

点击打开杭电1047 Problem Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers. ``This supercomputer is great,'' re

杭电ACM Java实现样例

若使用Java求解杭电ACM,答案提交必须注意两点: 1.类名一定得是Main,否则服务器无法编译: 2.必须用while进行输入判断. 以1000题测试题为例,代码如下: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan=new Scanner(System.in); while(scan.hasNextInt()) { int a=scan.n

魔咒词典------HDOJ杭电1880(字符串的处理,很简单)

Problem Description 哈利波特在魔法学校的必修课之一就是学习魔咒.据说魔法世界有100000种不同的魔咒,哈利很难全部记住,但是为了对抗强敌,他必须在危急时刻能够调用任何一个需要的魔咒,所以他需要你的帮助. 给你一部魔咒词典.当哈利听到一个魔咒时,你的程序必须告诉他那个魔咒的功能:当哈利需要某个功能但不知道该用什么魔咒时,你的程序要替他找到相应的魔咒.如果他要的魔咒不在词典中,就输出"what?" Input 首先列出词典中不超过100000条不同的魔咒词条,每条格式

HDOJ(HDU) 2500 做一个正气的杭电人(水~)

Problem Description 做人要有一身正气,杭电学子都应该如此.比如我们今天的考试就应该做到"诚信"为上. 每次考试的第一个题目总是很简单,今天也不例外,本题是要求输出指定大小的"HDU"字符串,特别地,为了体现"正气"二字,我们要求输出的字符串也是正方形的(行数和列数相等). Input 输入的第一行包含一个正整数N(N<=20),表示一共有N组数据,接着是N行数据,每行包含一个正整数M(M<=50),表示一行内有M个

hdoj 1290 献给杭电五十周年校庆的礼物 【几何模板】

献给杭电五十周年校庆的礼物 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7597    Accepted Submission(s): 4145 Problem Description 或许你曾经牢骚满腹 或许你依然心怀忧伤 或许你近在咫尺 或许你我天各一方 对于每一个学子 母校 永远航行在 生命的海洋 今年是我们杭电建校五十周年,

杭电1379(DNA Sorting)java面向对象编程

点击打开链杭电1379 Problem Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater t

杭电2005(第几天?)java字符串水过

点击打开杭电2005 1.split的应用:将字符串以某某字符为界划分为多个字符串 2.面向对象的编程 Problem Description 给定一个日期,输出这个日期是该年的第几天. Input 输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的. Output 对于每组输入数据,输出一行,表示该日期是该年的第几天. Sample Input 1985/1/20 2006/3/12 Sample Out

杭电2549(第一次用java写kmp算法)

点击打开杭电2549 Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren't aware we had. Marge: Yeah, what is it? Homer: Take me for example. I want to find out if I have a talent in politics, OK? Marge: OK. Home

Is It A Tree?------HDOJ杭电1325(两种方法,可以用也可以不用并查集!!!!!!详解)

Problem Description A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. There is exactly one node, called the