結果
問題 | No.593 4進FizzBuzz |
ユーザー |
![]() |
提出日時 | 2017-12-01 18:43:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 2,253 bytes |
コンパイル時間 | 2,808 ms |
コンパイル使用メモリ | 105,600 KB |
実行使用メモリ | 24,960 KB |
最終ジャッジ日時 | 2024-11-27 21:41:10 |
合計ジャッジ時間 | 4,650 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;class Scanner{private readonly char Separator = ' ';private int Index = 0;private string[] Line = new string[0];public string Next(){if (Index >= Line.Length){Line = Console.ReadLine().Split(Separator);Index = 0;}var ret = Line[Index];Index++;return ret;}public int NextInt(){return int.Parse(Next());}public long NextLong(){return long.Parse(Next());}public string[] StringArray(){Line = Console.ReadLine().Split(Separator);Index = Line.Length;return Line;}public int[] IntArray(){var l = StringArray();var res = new int[l.Length];for (int i = 0; i < l.Length; i++){res[i] = int.Parse(l[i]);}return res;}public long[] LongArray(){var l = StringArray();var res = new long[l.Length];for (int i = 0; i < l.Length; i++){res[i] = long.Parse(l[i]);}return res;}}class Program{private string S;private void Scan(){var sc = new Scanner();S = sc.Next();}public void Solve(){Scan();int three = 0;int five = 0;for (int i = S.Length - 1; i >= 0; i--){int n = S[i] - '0';int m = i - S.Length - 1;three += n;three %= 3;five += (m % 2 == 0 ? 1 : -1) * n;five %= 5;}if(three==0){if(five==0){Console.WriteLine("FizzBuzz");}else{Console.WriteLine("Fizz");}}else{if (five == 0){Console.WriteLine("Buzz");}else{Console.WriteLine(S);}}}static void Main(string[] args){new Program().Solve();}}