結果
問題 |
No.327 アルファベット列
|
ユーザー |
![]() |
提出日時 | 2016-05-12 10:29:02 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 586 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-05 13:53:53 |
合計ジャッジ時間 | 1,572 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 45 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:19:26: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 19 | printf("%c\n", 'A'+n); | ~^ ~~~~~ | | | | int ll {aka long long int} | %lld main.c:16:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%lld", &n); | ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> typedef long long ll; int calc(ll n, ll t, int c) { if( n <= t*27-1 ) return c; return calc( n, t*27, c+1); } int main(void) { int i, j, c; ll n; char s[10]; scanf("%lld", &n); if( n <= 25 ) { printf("%c\n", 'A'+n); return 0; } c = calc( n, 26, 2 ); s[c] = '\0'; for( i = 0; i < c-1; i++) { ll t = 26, u; for( j = 1; t*27-1 < n; j++) t *= 27; u = n/t; n -= t*u; if( u ) { s[i] = 'A'+(char)u-1; } else { s[i] = 'A'+u; } } s[c-1] = 'A'+n; for( i = 0; s[i] != '\0'; i++){ printf("%c", s[i]); } printf("\n"); return 0; }