結果

問題 No.593 4進FizzBuzz
ユーザー バカらっく
提出日時 2017-11-10 23:11:24
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,454 bytes
コンパイル時間 2,560 ms
コンパイル使用メモリ 109,184 KB
実行使用メモリ 70,592 KB
最終ジャッジ日時 2024-11-24 15:01:47
合計ジャッジ時間 61,534 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 2 RE * 1 TLE * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        String inpt = Reader.ReadLine();

        int[] list = inpt.Select(a => int.Parse(a.ToString())).ToArray();

        string ans = "";
        if(list.Sum() % 3 == 0) {
            ans = "Fizz";
        }
        if(CanBuzz(list)) {
            ans += "Buzz";
        }
        if(ans.Length == 0) {
            ans = inpt.ToString();
        }

        Console.WriteLine(ans);
        
    }

    private bool CanBuzz(int[] input) {
        List<int> num = input.ToList();
        int tmp = 0;
        while(num.Count >= 3) {
            tmp = num[0] * 100 + num[1] * 10 + num[0];
            tmp = tmp % 11;
            if(tmp == 10) {
                num.RemoveAt(0);
                num[0] = 1;
                num[1] = 0;
            } else if(tmp > 0) {
                num.RemoveAt(0);
                num.RemoveAt(1);
                num[0] = tmp;
            } else {
                num.RemoveAt(0);
                num.RemoveAt(1);
                num.RemoveAt(2);
            }
        }
        if(num.Count>=2) {
            tmp = num[0] * 10 + num[1];
            if(tmp % 11 == 0) {
                return true;
            }
        }
        return num.Count == 0;
    }

    private int ToDec(int num) {
        int ans = 0;
        if(num == 0) {
            return 0;
        }
        int[] tmp = num.ToString().Select(a => int.Parse(a.ToString())).Reverse().ToArray();
        ans += tmp[0];
        int mul = 4;
        for (int i = 1; i < tmp.Length; i++) {
            ans += mul * tmp[i];
            mul = mul * 4;
        }
        return ans;


    }





    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"

33

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0