結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー mbanmban
提出日時 2017-01-07 02:40:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,871 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 99,724 KB
実行使用メモリ 22,828 KB
最終ジャッジ日時 2023-09-29 22:38:24
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
22,828 KB
testcase_01 AC 58 ms
14,820 KB
testcase_02 AC 58 ms
14,636 KB
testcase_03 AC 58 ms
14,636 KB
testcase_04 AC 59 ms
14,752 KB
testcase_05 AC 59 ms
14,700 KB
testcase_06 AC 58 ms
14,660 KB
testcase_07 AC 58 ms
14,692 KB
testcase_08 AC 58 ms
14,748 KB
testcase_09 AC 59 ms
14,660 KB
testcase_10 AC 59 ms
14,692 KB
testcase_11 AC 58 ms
14,736 KB
testcase_12 AC 59 ms
14,712 KB
testcase_13 AC 58 ms
14,640 KB
testcase_14 AC 59 ms
14,692 KB
testcase_15 AC 60 ms
14,840 KB
testcase_16 AC 59 ms
14,764 KB
testcase_17 AC 58 ms
14,796 KB
testcase_18 AC 59 ms
14,732 KB
testcase_19 AC 63 ms
14,736 KB
testcase_20 AC 61 ms
22,716 KB
testcase_21 AC 59 ms
20,824 KB
testcase_22 AC 60 ms
20,816 KB
testcase_23 AC 61 ms
18,836 KB
testcase_24 AC 59 ms
20,808 KB
testcase_25 AC 58 ms
20,780 KB
testcase_26 AC 59 ms
22,788 KB
testcase_27 AC 59 ms
18,936 KB
testcase_28 AC 62 ms
22,796 KB
testcase_29 AC 60 ms
22,808 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;
            if(!Plus)
            Fre *= -1;
        }
        if (!Plus)
        {
            Console.Write("-");
        }
        Console.Write("{0}.{1}", Integer, Fre.ToString().PadLeft(10, '0'));
        Console.WriteLine();
        
    }
}
0