結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー scachescache
提出日時 2014-11-28 16:57:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 4,522 ms
コンパイル使用メモリ 77,240 KB
実行使用メモリ 56,500 KB
最終ジャッジ日時 2023-09-01 22:47:19
合計ジャッジ時間 10,446 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
56,460 KB
testcase_01 AC 138 ms
55,680 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 149 ms
55,920 KB
testcase_05 AC 143 ms
56,260 KB
testcase_06 AC 147 ms
55,852 KB
testcase_07 AC 150 ms
56,152 KB
testcase_08 AC 149 ms
55,784 KB
testcase_09 AC 152 ms
56,224 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 135 ms
56,068 KB
testcase_14 AC 134 ms
55,972 KB
testcase_15 AC 148 ms
56,056 KB
testcase_16 AC 133 ms
56,204 KB
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 135 ms
56,008 KB
testcase_26 AC 134 ms
56,224 KB
testcase_27 WA -
testcase_28 AC 134 ms
55,804 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 -= 1.0e3;
		fr += 1.0e13;
		
		in += fr/1.0e10;
		fr %= 1.0e10;
		System.out.println(String.format("%d.%010d", in ,Math.abs(fr)));
	}

}
0