結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー scachescache
提出日時 2014-11-28 16:32:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 4,612 ms
コンパイル使用メモリ 77,188 KB
実行使用メモリ 59,184 KB
最終ジャッジ日時 2023-09-01 22:42:05
合計ジャッジ時間 11,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 166 ms
56,844 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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 WA -
testcase_26 AC 163 ms
57,068 KB
testcase_27 WA -
testcase_28 WA -
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(in +"." + fr);
		
	}

}
0