結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー scachescache
提出日時 2014-11-28 17:06:53
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,026 bytes
コンパイル時間 4,097 ms
コンパイル使用メモリ 76,648 KB
実行使用メモリ 57,828 KB
最終ジャッジ日時 2023-08-21 12:57:29
合計ジャッジ時間 9,032 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
56,444 KB
testcase_01 AC 128 ms
55,944 KB
testcase_02 AC 129 ms
56,292 KB
testcase_03 AC 124 ms
54,420 KB
testcase_04 AC 142 ms
56,328 KB
testcase_05 AC 134 ms
56,708 KB
testcase_06 AC 138 ms
56,424 KB
testcase_07 AC 138 ms
56,136 KB
testcase_08 AC 138 ms
55,876 KB
testcase_09 AC 143 ms
55,928 KB
testcase_10 WA -
testcase_11 AC 134 ms
56,436 KB
testcase_12 AC 137 ms
55,892 KB
testcase_13 AC 126 ms
56,536 KB
testcase_14 AC 126 ms
56,396 KB
testcase_15 AC 140 ms
56,008 KB
testcase_16 AC 127 ms
56,308 KB
testcase_17 WA -
testcase_18 AC 140 ms
56,372 KB
testcase_19 AC 134 ms
56,152 KB
testcase_20 AC 129 ms
55,880 KB
testcase_21 WA -
testcase_22 AC 134 ms
55,632 KB
testcase_23 AC 141 ms
56,128 KB
testcase_24 AC 140 ms
56,132 KB
testcase_25 AC 126 ms
55,884 KB
testcase_26 AC 127 ms
55,988 KB
testcase_27 WA -
testcase_28 AC 126 ms
55,924 KB
testcase_29 AC 136 ms
56,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.text.NumberFormat;
import java.util.Scanner;

public class Main81 {
	public static void main(String[] args) {
		Main81 p = new Main81();
	}

	public Main81() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] a = new String[n];
		for(int i=0;i<n;i++)		
			a[i] = sc.next();
			
		solve(a);
	}

	private final int NUM_DIGITS = 10;
	public void solve(String[] a) {
		
		long in = 0;
		long fr = 0;
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMinimumFractionDigits(NUM_DIGITS);
		for(int j=0;j<a.length;j++){
			String[] s = (a[j]+".0").split("\\.");
			long l = Long.parseLong(s[0]);
			long f = Long.parseLong(nf.format(Double.parseDouble("0."+s[1])).substring(2));
			
			in += l;
			fr = fr + f * (s[0].charAt(0) == '-' ? (-1) : 1) ;
		
		}
		int sign = in>=0 ? 1 : -1;
		in -= 1.0e3 * sign;
		fr += 1.0e13 * sign;
		in += (long)(fr/1.0e10);
		fr %= 1.0e10;
		System.out.println(String.format("%d.%010d", in ,Math.abs(fr)));
	}

}
0