結果
問題 | No.593 4進FizzBuzz |
ユーザー |
![]() |
提出日時 | 2018-09-10 14:10:35 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 339 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 1,048 ms |
コンパイル使用メモリ | 103,552 KB |
実行使用メモリ | 28,928 KB |
最終ジャッジ日時 | 2024-12-29 13:38:01 |
合計ジャッジ時間 | 10,672 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; public class Hello { public static void Main() { var s = Console.ReadLine().Trim(); var sL = s.Length; var sum3 = 0; var conv5 = 0; for (int i = 0; i < sL; i++) { var w = int.Parse(s[sL -1 -i].ToString()); sum3 += w; var t = i % 2 == 0 ? 1 : 4; conv5 += (w * t) % 5; conv5 %= 5; } string ans; if (sum3 % 3 == 0 && conv5 == 0) ans = "FizzBuzz"; else if (sum3 % 3 == 0) ans = "Fizz"; else if (conv5 == 0) ans = "Buzz"; else ans = s; Console.WriteLine(ans); } }