結果

問題 No.327 アルファベット列
コンテスト
ユーザー kou6839
提出日時 2015-12-20 01:05:17
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 817 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,291 ms
コンパイル使用メモリ 88,060 KB
実行使用メモリ 42,384 KB
最終ジャッジ日時 2026-04-06 06:28:11
合計ジャッジ時間 6,525 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.net.NetworkInterface;
import java.util.*;

public class Main {
	static long gcd(long a,long b){
		return b == 0 ? a : gcd(b, a%b);
	}
	static long lcm(long a, long b){
		return a*b/gcd(a, b);
	}
	static int[] dx = {1,0,-1,0};
	static int[] dy = {0,1,0,-1};
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		String ans = "";
		ans+=(char)((int)'A'+n%26);
		if(n<=25){
			System.out.println(ans);
			return;
		}
		if(n==26){
			System.out.println("AA");
			return;
		}
		int ind = 1;
		long unti = 26;
		while(n>=26*Math.pow(27, ind)) {ind++;unti++;}
		ind--;
		String unko="";
		for(int i=ind;i>=0;i--){
			unko+=(char)((int)'A'+(int)(n/(26*Math.pow(27, i)))+(i==ind?-1:0));
			n%=Math.pow(27, i);
		}
		System.out.println(unko+ans);
	} 
}
0