結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 AC 161 ms
56,780 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 155 ms
56,912 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

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].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(in +"." + fr);
		
	}

}
0