結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2017-01-07 02:37:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,849 bytes |
コンパイル時間 | 863 ms |
コンパイル使用メモリ | 110,088 KB |
実行使用メモリ | 26,152 KB |
最終ジャッジ日時 | 2024-12-17 15:15:04 |
合計ジャッジ時間 | 2,483 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(); } }