結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー GrenacheGrenache
提出日時 2015-11-06 21:00:22
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,216 bytes
コンパイル時間 3,991 ms
コンパイル使用メモリ 79,856 KB
実行使用メモリ 58,388 KB
最終ジャッジ日時 2023-08-21 13:06:32
合計ジャッジ時間 9,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,112 KB
testcase_01 AC 122 ms
55,568 KB
testcase_02 AC 125 ms
55,684 KB
testcase_03 AC 120 ms
56,344 KB
testcase_04 AC 137 ms
56,308 KB
testcase_05 AC 129 ms
55,960 KB
testcase_06 AC 130 ms
56,200 KB
testcase_07 AC 129 ms
56,088 KB
testcase_08 AC 131 ms
56,288 KB
testcase_09 AC 134 ms
55,948 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 122 ms
55,960 KB
testcase_14 AC 123 ms
56,200 KB
testcase_15 AC 138 ms
56,148 KB
testcase_16 AC 125 ms
56,544 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 136 ms
56,304 KB
testcase_24 WA -
testcase_25 AC 119 ms
55,580 KB
testcase_26 AC 122 ms
53,576 KB
testcase_27 WA -
testcase_28 AC 123 ms
56,004 KB
testcase_29 AC 133 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

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 ((intp >= 0 && decimal >= 0) || (intp < 0 && decimal < 0)) {
        } else if (intp >= 0 && decimal < 0) {
        	intp--;
            decimal += 10000000000L;
        } else if (intp < 0 && decimal > 0) {
        	intp++;
            decimal = 10000000000L - decimal;
        }

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

        sc.close();
    }
}
0