結果

問題 No.593 4進FizzBuzz
ユーザー claw88claw88
提出日時 2017-11-10 22:38:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 2,287 bytes
コンパイル時間 3,049 ms
コンパイル使用メモリ 107,548 KB
実行使用メモリ 37,748 KB
最終ジャッジ日時 2023-08-16 03:19:18
合計ジャッジ時間 8,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
20,580 KB
testcase_01 AC 51 ms
20,576 KB
testcase_02 AC 52 ms
22,528 KB
testcase_03 AC 51 ms
20,516 KB
testcase_04 AC 51 ms
22,680 KB
testcase_05 AC 52 ms
20,600 KB
testcase_06 AC 51 ms
20,504 KB
testcase_07 AC 51 ms
20,528 KB
testcase_08 AC 51 ms
20,604 KB
testcase_09 AC 52 ms
22,668 KB
testcase_10 AC 51 ms
18,488 KB
testcase_11 AC 52 ms
22,500 KB
testcase_12 AC 52 ms
22,716 KB
testcase_13 AC 51 ms
20,736 KB
testcase_14 AC 51 ms
20,624 KB
testcase_15 AC 53 ms
22,548 KB
testcase_16 AC 165 ms
33,884 KB
testcase_17 AC 165 ms
31,872 KB
testcase_18 AC 167 ms
33,768 KB
testcase_19 AC 178 ms
35,900 KB
testcase_20 AC 166 ms
31,844 KB
testcase_21 AC 165 ms
33,764 KB
testcase_22 AC 177 ms
35,628 KB
testcase_23 AC 166 ms
31,868 KB
testcase_24 AC 165 ms
31,780 KB
testcase_25 AC 165 ms
31,780 KB
testcase_26 AC 178 ms
35,708 KB
testcase_27 AC 177 ms
35,672 KB
testcase_28 AC 164 ms
31,804 KB
testcase_29 AC 177 ms
37,748 KB
testcase_30 AC 165 ms
31,988 KB
testcase_31 AC 165 ms
31,896 KB
testcase_32 AC 165 ms
31,872 KB
testcase_33 AC 178 ms
35,892 KB
testcase_34 AC 165 ms
31,952 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.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var Q = cin.next.ToCharArray();
        Array.Reverse(Q);
        long a3 = 0;
        long d3 = 1;
        long a5 = 0;
        long d5 = 1;
        for (int i = 0; i < Q.Length; i++)
        {
            a3 += d3 * (Q[i] - '0');
            a3 %= 3;
            d3 = (d3 * 4) % 3;

            a5 += d5 * (Q[i] - '0');
            a5 %= 5;
            d5 = (d5 * 4) % 5;
        }
        if (a3 % 3 == 0 || a5 % 5 == 0)
        {
            if (a3 % 3 == 0)
            {
                Write("Fizz");
            }
            if (a5 % 5 == 0)
            {
                Write("Buzz");
            }
            WriteLine();
        }
        else
        {
            Array.Reverse(Q);
            WriteLine(new string(Q));
        }
        
    }
    
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}   
0