結果

問題 No.593 4進FizzBuzz
ユーザー papinianus
提出日時 2017-11-14 13:57:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 114,576 KB
実行使用メモリ 45,844 KB
最終ジャッジ日時 2024-11-25 02:03:37
合計ジャッジ時間 6,741 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using static System.Console;
using static System.String;

namespace No593
{
    class Program
    {
        static void Main(string[] args)
        {
            var p4 = ReadLine().Trim();
            WriteLine(ToFizzBuzzString(p4));
        }
        static string ToFizzBuzzString(string p4)
        {
            var isTriple = p4.ToCharArray().Select(x => Convert.ToInt64(x)).Sum() % 3 == 0;
            var evens = p4.ToCharArray().Where((x, i) => i % 2 == 0).Select(x => Convert.ToInt64(x)).Sum();
            var odds = p4.ToCharArray().Where((x, i) => i % 2 == 1).Select(x => Convert.ToInt64(x)).Sum();
            var isQuintuple = Math.Abs(evens - odds) % 5 == 0;
            return $"{(isTriple ? "Fizz" : Empty)}{(isQuintuple ? "Buzz" : Empty)}{(!isTriple && !isQuintuple ? p4 : Empty)}";
        }
    }
}
0