結果

問題 No.593 4進FizzBuzz
ユーザー mbanmban
提出日時 2017-12-01 18:43:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 2,253 bytes
コンパイル時間 3,856 ms
コンパイル使用メモリ 103,692 KB
実行使用メモリ 30,028 KB
最終ジャッジ日時 2023-08-18 15:27:29
合計ジャッジ時間 8,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
22,476 KB
testcase_01 AC 48 ms
20,484 KB
testcase_02 AC 48 ms
18,488 KB
testcase_03 AC 52 ms
20,512 KB
testcase_04 AC 49 ms
20,596 KB
testcase_05 AC 50 ms
22,560 KB
testcase_06 AC 50 ms
22,648 KB
testcase_07 AC 50 ms
20,588 KB
testcase_08 AC 100 ms
20,544 KB
testcase_09 AC 50 ms
22,512 KB
testcase_10 AC 51 ms
22,520 KB
testcase_11 AC 50 ms
18,568 KB
testcase_12 AC 50 ms
20,500 KB
testcase_13 AC 51 ms
18,440 KB
testcase_14 AC 50 ms
18,576 KB
testcase_15 AC 49 ms
20,492 KB
testcase_16 AC 93 ms
25,868 KB
testcase_17 AC 92 ms
29,848 KB
testcase_18 AC 92 ms
27,860 KB
testcase_19 AC 99 ms
30,012 KB
testcase_20 AC 92 ms
30,016 KB
testcase_21 AC 93 ms
27,848 KB
testcase_22 AC 98 ms
29,936 KB
testcase_23 AC 92 ms
29,956 KB
testcase_24 AC 92 ms
27,860 KB
testcase_25 AC 92 ms
27,948 KB
testcase_26 AC 98 ms
25,792 KB
testcase_27 AC 105 ms
27,872 KB
testcase_28 AC 93 ms
29,944 KB
testcase_29 AC 99 ms
30,028 KB
testcase_30 AC 92 ms
27,972 KB
testcase_31 AC 92 ms
29,916 KB
testcase_32 AC 93 ms
29,884 KB
testcase_33 AC 99 ms
27,948 KB
testcase_34 AC 92 ms
27,852 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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();
    }
}
0