結果

問題 No.327 アルファベット列
ユーザー suppy193
提出日時 2017-02-02 14:35:50
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-24 03:52:06
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%lld", &n);
      |         ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void) {
	long long int n;
	char s[20] = {0};
	int i;
	scanf("%lld", &n);

	s[0] = n % 26 + 'A';
	n /= 26;
	i = 1;
	while(n > 0) {
		if(s[i - 1] != 'Z'){
			s[i] = (n + 25) % 26 + 'A';
		}
		else if(s[i - 1] == 'Z' && (n + 25) % 26 == 0){
			s[i] = 'Z';
		}
		else{
			s[i] = (n + 25) % 26 - 1 + 'A';
		}
		if(n == 26){
			i++;
			break;
		}
		n = n / 26;
		i++;
	}
	s[i] = '\0';
	//printf("%s\n", s);
	i--;
	do {
		printf("%c", s[i]);
		i--;
	}while(i >= 0);
	printf("\n");

	return 0;
}
0