結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-02 03:31:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,181 bytes
コンパイル時間 2,559 ms
コンパイル使用メモリ 76,028 KB
実行使用メモリ 58,808 KB
最終ジャッジ日時 2023-08-18 12:07:33
合計ジャッジ時間 8,527 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 147 ms
56,752 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 AC 160 ms
56,744 KB
testcase_12 AC 157 ms
56,860 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 157 ms
54,788 KB
testcase_16 AC 151 ms
56,480 KB
testcase_17 AC 148 ms
56,820 KB
testcase_18 WA -
testcase_19 AC 151 ms
56,712 KB
testcase_20 AC 148 ms
56,608 KB
testcase_21 AC 146 ms
56,904 KB
testcase_22 AC 153 ms
56,732 KB
testcase_23 WA -
testcase_24 AC 150 ms
56,948 KB
testcase_25 WA -
testcase_26 AC 145 ms
56,760 KB
testcase_27 AC 147 ms
56,748 KB
testcase_28 WA -
testcase_29 AC 150 ms
56,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long sum=0;
        for(int i=0; i<N; i++){
            String S = sc.next();
            sum+=inde(S);
        }
        long m=1000000000L;
        if(sum>0){
            long ans1=sum/m;
            long ans2=sum%m;
            System.out.println(ans1+"."+ans2+"0");
        }else{
            sum*=-1;
            long ans1=sum/m;
            long ans2=sum%m;
            System.out.println("-"+ans1+"."+ans2+"0");            
        }
    }
    static long inde(String S){
        long m=1000000000L;
        int t = S.indexOf(".");
        long x;
        if(t==-1){
            x=Long.parseLong(S)*m;
        }else{
            String S1=S.substring(0,t);
            String S2=S.substring(t+1);
            while(S2.length()<9){
                S2=S2+"0";
            }
            long x1=Long.parseLong(S1)*m;
            long x2=Long.parseLong(S2);
            if(S.contains("-")){
                x=x1-x2;
            }else{
                x=x1+x2;
            }
        }
        return x;
    }
}
0