結果

問題 No.327 アルファベット列
ユーザー jp_stejp_ste
提出日時 2016-02-01 08:18:26
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 834 bytes
コンパイル時間 2,400 ms
コンパイル使用メモリ 80,564 KB
実行使用メモリ 58,484 KB
最終ジャッジ日時 2023-10-21 18:27:46
合計ジャッジ時間 12,233 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,460 KB
testcase_01 AC 128 ms
57,388 KB
testcase_02 AC 156 ms
58,384 KB
testcase_03 AC 158 ms
58,312 KB
testcase_04 AC 157 ms
58,468 KB
testcase_05 AC 159 ms
58,484 KB
testcase_06 AC 160 ms
58,444 KB
testcase_07 AC 164 ms
58,428 KB
testcase_08 AC 163 ms
58,420 KB
testcase_09 AC 163 ms
58,332 KB
testcase_10 AC 162 ms
58,380 KB
testcase_11 AC 160 ms
58,400 KB
testcase_12 AC 162 ms
58,464 KB
testcase_13 AC 160 ms
58,116 KB
testcase_14 AC 161 ms
58,160 KB
testcase_15 AC 161 ms
58,344 KB
testcase_16 AC 162 ms
58,480 KB
testcase_17 AC 163 ms
58,328 KB
testcase_18 AC 164 ms
58,468 KB
testcase_19 AC 164 ms
58,368 KB
testcase_20 AC 163 ms
58,268 KB
testcase_21 AC 149 ms
57,872 KB
testcase_22 AC 160 ms
58,476 KB
testcase_23 AC 158 ms
58,232 KB
testcase_24 AC 163 ms
58,408 KB
testcase_25 AC 160 ms
58,480 KB
testcase_26 AC 160 ms
58,372 KB
testcase_27 AC 160 ms
58,404 KB
testcase_28 AC 161 ms
58,400 KB
testcase_29 AC 163 ms
58,372 KB
testcase_30 AC 161 ms
58,412 KB
testcase_31 AC 159 ms
58,404 KB
testcase_32 AC 160 ms
58,292 KB
testcase_33 AC 159 ms
58,476 KB
testcase_34 AC 158 ms
58,368 KB
testcase_35 AC 161 ms
58,360 KB
testcase_36 AC 162 ms
58,260 KB
testcase_37 AC 157 ms
56,512 KB
testcase_38 AC 161 ms
58,396 KB
testcase_39 AC 157 ms
58,476 KB
testcase_40 AC 157 ms
58,348 KB
testcase_41 AC 157 ms
58,332 KB
testcase_42 AC 158 ms
56,532 KB
testcase_43 AC 160 ms
58,296 KB
testcase_44 AC 162 ms
58,404 KB
testcase_45 AC 158 ms
58,432 KB
testcase_46 AC 157 ms
58,464 KB
testcase_47 AC 159 ms
58,400 KB
testcase_48 AC 161 ms
58,416 KB
testcase_49 AC 157 ms
58,368 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 161 ms
58,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		scan.close();
		
		if(N < 26) {
			System.out.println((char)(N+'A'));
		} else {
			ArrayList<Long> list = new ArrayList();
			long value = N;
			while(true) {
				long tmp1 = value / 26;
				long tmp2 = value % 26;
				list.add(tmp2);
				if(tmp1 <= 26) {
					list.add(tmp1);
					break;
				}
				value = tmp1;
			}
			
			int n = list.size();
			String out = "";
			for(int i=0; i<n; i++) {
				long v = list.get(i);
				if(i>0) {
					v--;
					if(v==-1) {
						v=25L;
						if(i<n-1) {
							long v2 = list.get(i+1);
							list.set(i+1, v2-1);
						}
					}
				}
				out = (char)(v+'A') + out;
			}
			System.out.println(out);
		}
	}
}
0