結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-05-15 05:43:23 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,792 bytes |
| コンパイル時間 | 1,494 ms |
| コンパイル使用メモリ | 107,136 KB |
| 実行使用メモリ | 232,300 KB |
| 最終ジャッジ日時 | 2024-10-06 03:09:35 |
| 合計ジャッジ時間 | 7,460 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | -- * 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);
ret.ForEach(a => ans.Add(Convert.ToInt64("1" + Convert.ToString(a, 2).PadLeft(remain3 + remain5 - 1, '0'),2)));
}
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();
}
}
14番