結果
問題 | No.294 SuperFizzBuzz |
ユーザー |
![]() |
提出日時 | 2016-05-15 05:50:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,723 ms / 5,000 ms |
コード長 | 2,769 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 115,252 KB |
実行使用メモリ | 293,040 KB |
最終ジャッジ日時 | 2024-10-06 03:10:35 |
合計ジャッジ時間 | 12,869 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
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.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();}}