結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-01-07 02:40:04 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 1,871 bytes |
| コンパイル時間 | 2,599 ms |
| コンパイル使用メモリ | 113,880 KB |
| 実行使用メモリ | 26,144 KB |
| 最終ジャッジ日時 | 2024-07-22 16:37:47 |
| 合計ジャッジ時間 | 4,109 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
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;
if(!Plus)
Fre *= -1;
}
if (!Plus)
{
Console.Write("-");
}
Console.Write("{0}.{1}", Integer, Fre.ToString().PadLeft(10, '0'));
Console.WriteLine();
}
}
mban