結果
問題 |
No.593 4進FizzBuzz
|
ユーザー |
|
提出日時 | 2017-11-14 14:09:47 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 199 ms / 2,000 ms |
コード長 | 1,547 bytes |
コンパイル時間 | 915 ms |
コンパイル使用メモリ | 111,832 KB |
実行使用メモリ | 45,560 KB |
最終ジャッジ日時 | 2024-11-25 08:50:44 |
合計ジャッジ時間 | 6,778 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using static System.Console; using static System.String; //using System.Reactive.Linq; 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 => x - '0').Sum() % 3 == 0; var evens = p4.ToCharArray().Where((x, i) => i % 2 == 0).Select(x => x - '0').Sum(); var odds = p4.ToCharArray().Where((x, i) => i % 2 == 1).Select(x => x - '0').Sum(); var isQuintuple = Math.Abs(evens - odds) % 5 == 0; return $"{(isTriple ? "Fizz" : Empty)}{(isQuintuple ? "Buzz" : Empty)}{(!isTriple && !isQuintuple ? p4 : Empty)}"; } //static string ToFizzBuzzStringInReactive(string p4) //{ // var isTriple = p4.ToCharArray().Select(x => x - '0').Sum() % 3 == 0; // var isQuintuple = false; // p4.ToCharArray().Select((x, i) => new { index = i, val = x - '0' }).ToObservable() // .Publish(rx => rx.Where(ri => ri.index % 2 == 0).Select(rv => rv.val).Sum() // .Zip(rx.Where(rj => rj.index % 2 == 1).Select(rw => rw.val).Sum(), (even, odd) => Math.Abs(even - odd) % 5 == 0)).Subscribe(r => isQuintuple = r); // return $"{(isTriple ? "Fizz" : Empty)}{(isQuintuple ? "Buzz" : Empty)}{(!isTriple && !isQuintuple ? p4 : Empty)}"; //} } }