結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー mbanmban
提出日時 2017-01-07 02:37:21
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,849 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 105,884 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-08-22 15:38:25
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
22,748 KB
testcase_01 AC 61 ms
18,800 KB
testcase_02 AC 63 ms
22,772 KB
testcase_03 AC 62 ms
20,704 KB
testcase_04 AC 62 ms
22,764 KB
testcase_05 AC 62 ms
20,776 KB
testcase_06 AC 62 ms
20,828 KB
testcase_07 AC 63 ms
20,716 KB
testcase_08 AC 62 ms
22,788 KB
testcase_09 AC 64 ms
22,696 KB
testcase_10 AC 63 ms
22,756 KB
testcase_11 AC 62 ms
20,880 KB
testcase_12 AC 62 ms
20,872 KB
testcase_13 AC 63 ms
20,756 KB
testcase_14 AC 62 ms
20,756 KB
testcase_15 AC 63 ms
22,760 KB
testcase_16 AC 63 ms
22,824 KB
testcase_17 AC 62 ms
22,764 KB
testcase_18 AC 62 ms
20,716 KB
testcase_19 AC 63 ms
22,680 KB
testcase_20 AC 62 ms
20,864 KB
testcase_21 AC 63 ms
20,856 KB
testcase_22 AC 63 ms
20,816 KB
testcase_23 AC 62 ms
20,884 KB
testcase_24 AC 62 ms
20,644 KB
testcase_25 AC 61 ms
20,708 KB
testcase_26 WA -
testcase_27 AC 63 ms
22,756 KB
testcase_28 AC 61 ms
22,908 KB
testcase_29 AC 62 ms
20,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    static int N = int.Parse(Console.ReadLine());
    const long MOD = 10000000000;
    static void Main()
    {
        long Integer = 0;
        long Fre = 0;
        for (int i = 0; i < N; i++)
        {
            string num = Console.ReadLine();

            bool pos = num[0] != '-';
            if (!pos)
            {
                num = num.Remove(0, 1);
            }
            string[] n = num.Split('.');
            if (pos)
            {
                Integer += long.Parse(n[0]);
                if (n.Length == 2)
                {
                    Fre += long.Parse(n[1].PadRight(10, '0'));
                }
            }
            else
            {
                Integer -= long.Parse(n[0]);
                if (n.Length == 2)
                {
                    Fre -= long.Parse(n[1].PadRight(10, '0'));
                }
            }
        }
        Integer += Fre / MOD;
        Fre %= MOD;
        bool Plus;
        if (Integer > 0)
        {
            Plus = true;
            if (Fre < 0)
            {
                Integer--;
                Fre += MOD;
            }
        }
        else if (Integer < 0)
        {
            Plus = false;
            if (Fre > 0)
            {
                Integer++;
                Fre -= MOD;
            }
            Fre *= -1;
            Integer *= -1;
        }
        else
        {
            Plus = Fre >= 0;
            Fre *= -1;
        }
        if (!Plus)
        {
            Console.Write("-");
        }
        Console.Write("{0}.{1}", Integer, Fre.ToString().PadLeft(10, '0'));
        Console.WriteLine();
        
    }
}
0