結果

問題 No.327 アルファベット列
ユーザー Mcpu3
提出日時 2018-10-26 16:08:35
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 06:07:05
合計ジャッジ時間 2,033 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void push(char tmp, char ans[], int *top)
{
	ans[*top] = tmp;
	++*top;
	ans[*top] = '\0';
}

void reverse(char ans[], int top)
{
	char tmp;
	int i;
	for (i = 0; i < top / 2; ++i) {
		tmp = ans[i];
		ans[i] = ans[top - i - 1];
		ans[top - i - 1] = tmp;
	}
}

int main(void)
{
	char ans[10];
	int top = 0;
	long N;
	scanf("%ld", &N);
	++N;
	while (N) {
		--N;
		push(N % 26 + 'A', ans, &top);
		N /= 26;
	}
	reverse(ans, top);
	puts(ans);
	return 0;
}
0