結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー GrenacheGrenache
提出日時 2015-11-06 20:47:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 3,654 ms
コンパイル使用メモリ 84,396 KB
実行使用メモリ 58,420 KB
最終ジャッジ日時 2023-10-11 14:24:32
合計ジャッジ時間 9,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,812 KB
testcase_01 AC 131 ms
56,048 KB
testcase_02 AC 134 ms
55,804 KB
testcase_03 WA -
testcase_04 AC 146 ms
55,924 KB
testcase_05 AC 138 ms
55,900 KB
testcase_06 AC 139 ms
55,748 KB
testcase_07 AC 138 ms
58,420 KB
testcase_08 AC 141 ms
55,584 KB
testcase_09 AC 142 ms
55,640 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 132 ms
55,720 KB
testcase_14 AC 132 ms
56,044 KB
testcase_15 AC 146 ms
55,972 KB
testcase_16 AC 133 ms
56,036 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 126 ms
55,908 KB
testcase_26 AC 130 ms
56,092 KB
testcase_27 WA -
testcase_28 AC 132 ms
56,324 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder81 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long decimal = 0;
        long intp = 0;
        for (int i = 0; i < n; i++) {
        	String a = sc.next();

        	int index = a.indexOf('.');
        	if (index == -1) {
        		intp += Long.parseLong(a);
        	} else {
                long sign = 1;
        		if (a.charAt(0) == '-') {
        			sign = -1;
        		}
        		intp += Long.parseLong(a.substring(0, index));
        		String tmp = a.substring(index + 1);
        		while (tmp.length() < 10) {
        			tmp += "0";
        		}
        		decimal += sign * Long.parseLong(tmp);
        	}
        }

        intp += decimal / 10000000000L;
        decimal %= 10000000000L;
        if (decimal < 0) {
        	intp--;
            decimal += 10000000000L;
        }
        decimal %= 10000000000L;

        System.out.printf("%d.%010d\n", intp, decimal);

        sc.close();
    }
}
0