結果

問題 No.327 アルファベット列
ユーザー koyumeishikoyumeishi
提出日時 2015-12-20 10:06:46
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 61,308 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 21:38:41
合計ジャッジ時間 1,894 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

long long pow_(long long x, long long y){
	if(x==0) return 0;
	long long ret = 1;
	while(y){
		if(y&1) ret *= x;
		x = x*x;
		y >>= 1;
	}
	return ret;
}

long long func(long long k){
	return (pow_(26, k) - 1)*26 / 25;
}

int main(){
	long long n;
	cin >> n;
	n++;
	
	long long len = 1;
	while(n-func(len) > 0){
		len++;
	}
	n--;
	string ans = "";
	for(int i=0; i<len; i++){
		ans += 'A' + n%26;
		n /= 26;
		n--;
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}
0