結果

問題 No.294 SuperFizzBuzz
ユーザー 14番14番
提出日時 2016-05-15 05:50:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,882 ms / 5,000 ms
コード長 2,769 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 113,008 KB
実行使用メモリ 308,404 KB
最終ジャッジ日時 2024-04-15 21:44:12
合計ジャッジ時間 14,221 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,172 KB
testcase_01 AC 34 ms
24,308 KB
testcase_02 AC 1,882 ms
302,696 KB
testcase_03 AC 33 ms
26,292 KB
testcase_04 AC 33 ms
24,112 KB
testcase_05 AC 33 ms
24,304 KB
testcase_06 AC 34 ms
24,444 KB
testcase_07 AC 35 ms
24,044 KB
testcase_08 AC 146 ms
56,392 KB
testcase_09 AC 944 ms
166,524 KB
testcase_10 AC 1,880 ms
308,404 KB
testcase_11 AC 1,862 ms
305,032 KB
testcase_12 AC 1,868 ms
307,208 KB
testcase_13 AC 1,862 ms
300,840 KB
testcase_14 AC 1,867 ms
302,876 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.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        this.Ans(int.Parse(Reader.ReadLine()));

    }

    private void Ans(int target)
    {
        int totalCount = 0;
        string ans = string.Empty;
        for (int i = 3; i <= 26 && totalCount <= target; i++)
        {
            List<long> subTotal = new List<long>();
            for (int j = 1; j * 3 <= i; j++)
            {
                List<long> list = this.GetListSub(i - (j * 3), j * 3);
                subTotal.AddRange(list);
            }
            if (totalCount + subTotal.Count >= target)
            {
                subTotal.Sort();
                string tmp = Convert.ToString(subTotal[target - totalCount - 1], 2).PadLeft(i, '0');
                tmp = tmp.Replace('0', '3');
                tmp = tmp.Replace('1', '5');
                Console.WriteLine(tmp);
                return;

            }
            totalCount += subTotal.Count;
        }

    }


    private Dictionary<int, Dictionary<int, List<long>>> dic = new Dictionary<int, Dictionary<int, List<long>>>();



    private List<long> GetListSub(int remain3, int remain5)
    {
        if (!dic.ContainsKey(remain3))
        {
            dic.Add(remain3, new Dictionary<int, List<long>>());
        }
        if (dic[remain3].ContainsKey(remain5))
        {
            return new List<long>(dic[remain3][remain5]);
        }
        List<long> ans = new List<long>();

        if (remain3 == 0)
        {
            ans.Add(Convert.ToInt64( "1".PadLeft(remain5, '1'),2));
        }
        else if (remain5 == 0)
        {
            //
        }
        else
        {
            List<long> ret = this.GetListSub(remain3 - 1, remain5);
            ret.ForEach(a => ans.Add(a));
            ret = this.GetListSub(remain3, remain5 - 1);
            long add = 1 << (remain3 + remain5 - 1);
            ret.ForEach(a => ans.Add(a + add));
        }
        dic[remain3].Add(remain5, ans);
        return ans;
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"
 

10000000





 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }

    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0