結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー | tenten |
提出日時 | 2020-11-18 17:38:32 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 149 ms / 5,000 ms |
コード長 | 2,420 bytes |
コンパイル時間 | 2,024 ms |
コンパイル使用メモリ | 76,616 KB |
実行使用メモリ | 57,944 KB |
最終ジャッジ日時 | 2023-09-29 22:56:53 |
合計ジャッジ時間 | 7,563 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 138 ms
56,048 KB |
testcase_01 | AC | 138 ms
56,052 KB |
testcase_02 | AC | 139 ms
56,052 KB |
testcase_03 | AC | 140 ms
57,944 KB |
testcase_04 | AC | 145 ms
55,912 KB |
testcase_05 | AC | 142 ms
56,380 KB |
testcase_06 | AC | 145 ms
56,560 KB |
testcase_07 | AC | 145 ms
55,844 KB |
testcase_08 | AC | 145 ms
56,212 KB |
testcase_09 | AC | 147 ms
56,740 KB |
testcase_10 | AC | 120 ms
55,804 KB |
testcase_11 | AC | 141 ms
56,288 KB |
testcase_12 | AC | 142 ms
56,068 KB |
testcase_13 | AC | 137 ms
56,004 KB |
testcase_14 | AC | 139 ms
55,784 KB |
testcase_15 | AC | 146 ms
55,884 KB |
testcase_16 | AC | 141 ms
56,068 KB |
testcase_17 | AC | 120 ms
55,844 KB |
testcase_18 | AC | 149 ms
56,016 KB |
testcase_19 | AC | 143 ms
56,584 KB |
testcase_20 | AC | 139 ms
56,052 KB |
testcase_21 | AC | 141 ms
56,368 KB |
testcase_22 | AC | 141 ms
56,052 KB |
testcase_23 | AC | 145 ms
56,020 KB |
testcase_24 | AC | 143 ms
56,288 KB |
testcase_25 | AC | 137 ms
55,748 KB |
testcase_26 | AC | 138 ms
56,152 KB |
testcase_27 | AC | 123 ms
55,756 KB |
testcase_28 | AC | 139 ms
56,336 KB |
testcase_29 | AC | 142 ms
56,068 KB |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long big = 0; long small = 0; for (int i = 0; i < n; i++) { char[] arr = sc.next().toCharArray(); long x = 0; long y = 0; int count = 0; boolean isPlus = true; boolean hasDot = false; for (int j = 0; j < arr.length || (hasDot && count < 10); j++) { if (!hasDot && arr[j] == '-') { isPlus = false; } else if (!hasDot && arr[j] == '.') { hasDot = true; } else { if (!hasDot) { x *= 10; x += arr[j] - '0'; } else { y *= 10; count++; if (j < arr.length) { y += arr[j] - '0'; } } } } if (isPlus) { big += x; small += y; } else { big -= x; small -= y; } } if (small <= -10000000000L) { big += small / 10000000000L; small = -(-small % 10000000000L); } else if (small >= 10000000000L) { big += small / 10000000000L; small %= 10000000000L; } if (big == 0 && small < 0) { small = -small; System.out.printf("-0.%010d\n", small); return; } if (small < 0) { if (big >= 0) { big--; if (big == 0) { small = -small; System.out.printf("-0.%010d\n", small); return; } small = 10000000000L + small; } else { small = -small; } } else { if (big < 0 && small != 0) { big++; small = 10000000000L - small; if (big == 0) { System.out.printf("-0.%010d\n", small); return; } } } System.out.print(big + "."); System.out.printf("%010d\n", small); } }