結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2020-11-18 17:34:04 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,108 bytes |
コンパイル時間 | 2,417 ms |
コンパイル使用メモリ | 80,028 KB |
実行使用メモリ | 54,572 KB |
最終ジャッジ日時 | 2024-07-23 09:07:36 |
合計ジャッジ時間 | 8,049 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 1 |
ソースコード
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--;small = 10000000000L + small;} else {small = -small;}} else {if (big < 0 && small != 0) {big++;small = 10000000000L - small;}}System.out.print(big + ".");System.out.printf("%010d\n", small);}}