結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー scachescache
提出日時 2014-11-28 16:33:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 3,724 ms
コンパイル使用メモリ 76,276 KB
実行使用メモリ 57,576 KB
最終ジャッジ日時 2023-09-01 22:44:40
合計ジャッジ時間 9,421 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,820 KB
testcase_01 AC 134 ms
56,188 KB
testcase_02 AC 137 ms
55,676 KB
testcase_03 WA -
testcase_04 AC 144 ms
55,712 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 146 ms
55,692 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 128 ms
55,904 KB
testcase_14 AC 129 ms
55,776 KB
testcase_15 WA -
testcase_16 WA -
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 130 ms
56,000 KB
testcase_26 AC 130 ms
55,928 KB
testcase_27 WA -
testcase_28 AC 128 ms
56,148 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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) ;
		
		}
		in += (long)(fr/1.0e10);
		fr %= 1.0e10;
		System.out.println(String.format("%d.%010d", in ,fr));
		
	}

}
0