結果

問題 No.327 アルファベット列
ユーザー ym678
提出日時 2016-09-03 13:21:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 4,777 ms
コンパイル使用メモリ 77,584 KB
実行使用メモリ 54,700 KB
最終ジャッジ日時 2024-11-15 18:33:27
合計ジャッジ時間 10,772 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		long N = sc.nextLong();
		int alp = (int) (N%26);
		N /= 26;
		str(alp,sb);
		
		while(N > 0){
			N --;
			alp = (int) (N%26);
			N /= 26;			
			str(alp,sb);
		}

		
		sb.reverse();
		String ans = sb.toString();
		System.out.println(ans);
	}
	
	public static void str(int alp,StringBuilder sb){

		if(alp == 0){
			sb.append("A");
		}else if(alp == 1){
			sb.append("B");
		}else if(alp == 2){
			sb.append("C");
		}else if(alp == 3){
			sb.append("D");
		}else if(alp == 4){
			sb.append("E");
		}else if(alp == 5){
			sb.append("F");
		}else if(alp == 6){
			sb.append("G");
		}else if(alp == 7){
			sb.append("H");
		}else if(alp == 8){
			sb.append("I");
		}else if(alp == 9){
			sb.append("J");
		}else if(alp == 10){
			sb.append("K");
		}else if(alp == 11){
			sb.append("L");
		}else if(alp == 12){
			sb.append("M");
		}else if(alp == 13){
			sb.append("N");
		}else if(alp == 14){
			sb.append("O");
		}else if(alp == 15){
			sb.append("P");
		}else if(alp == 16){
			sb.append("Q");
		}else if(alp == 17){
			sb.append("R");
		}else if(alp == 18){
			sb.append("S");
		}else if(alp == 19){
			sb.append("T");
		}else if(alp == 20){
			sb.append("U");
		}else if(alp == 21){
			sb.append("V");
		}else if(alp == 22){
			sb.append("W");
		}else if(alp == 23){
			sb.append("X");
		}else if(alp == 24){
			sb.append("Y");
		}else if(alp == 25){
			sb.append("Z");
		}
	}
}
		
		
0