結果
問題 | No.327 アルファベット列 |
ユーザー |
![]() |
提出日時 | 2016-06-11 19:23:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 2,236 bytes |
コンパイル時間 | 997 ms |
コンパイル使用メモリ | 112,100 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-10-09 12:59:01 |
合計ジャッジ時間 | 3,697 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
コンパイルメッセージ
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 = long.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());}}