結果
| 問題 |
No.327 アルファベット列
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-13 07:48:57 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 2,273 bytes |
| コンパイル時間 | 849 ms |
| コンパイル使用メモリ | 114,128 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-10-13 07:49:01 |
| 合計ジャッジ時間 | 3,386 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("0");
//A
//0はAに対応します
}
else if (InputPattern == "Input2") {
WillReturn.Add("25");
//Z
}
else if (InputPattern == "Input3") {
WillReturn.Add("26");
//AA
//Zの次は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());
}
}
aketijyuuzou