結果
問題 |
No.327 アルファベット列
|
ユーザー |
![]() |
提出日時 | 2016-06-11 19:21:28 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,235 bytes |
コンパイル時間 | 1,603 ms |
コンパイル使用メモリ | 111,684 KB |
実行使用メモリ | 27,520 KB |
最終ジャッジ日時 | 2024-10-09 12:58:57 |
合計ジャッジ時間 | 4,473 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 RE * 31 |
コンパイルメッセージ
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.Linq; //No.327 アルファベット列 class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("0"); //A } else if (InputPattern == "Input2") { WillReturn.Add("25"); //Z } else if (InputPattern == "Input3") { WillReturn.Add("26"); //AA } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); long N = int.Parse(InputList[0]); Solve(N); } static void Solve(long pN) { long ZentaiBanme = pN + 1; //全体の何番目を求めるか //群ごとの項数を求める long CurrGunCnt = 26; var GunKousuuList = new List<long>(); while (true) { GunKousuuList.Add(CurrGunCnt); if (GunKousuuList.Sum() > ZentaiBanme) break; CurrGunCnt *= 26; } long RunSum = 0; long GunBanme = ZentaiBanme; //対象群の何番目を求めるか long TargetGunLength = 1; for (int I = 0; I <= GunKousuuList.Count - 1; I++) { RunSum += GunKousuuList[I]; if (ZentaiBanme <= RunSum) { TargetGunLength = I + 1; break; } GunBanme -= GunKousuuList[I]; } long TargetNum = GunBanme - 1; var NumList = new List<long>(); do { NumList.Add(TargetNum % 26); TargetNum /= 26; } while (TargetNum > 0); while (NumList.Count < TargetGunLength) NumList.Add(0); NumList.Reverse(); var sb = new System.Text.StringBuilder(); int UB = NumList.Count - 1; for (int I = 0; I <= UB; I++) { char wkChar = (char)('A' + (char)NumList[I]); sb.Append(wkChar); } Console.WriteLine(sb.ToString()); } }