結果

問題 No.327 アルファベット列
ユーザー Ysmr_Ry
提出日時 2016-03-03 20:04:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 37,760 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 13:53:53
合計ジャッジ時間 1,483 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf( "%lld", &N );
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

// yukicoder 327 (http://yukicoder.me/problems/904)
#include<cstdio>
#include<vector>
#define repd(i,a) for(int i=(a);i>=0;--i)

typedef long long ll;

ll N;

std::vector<int> ts, vs;

ll powLL( ll x, ll n )
{
	ll ret = 1;

	for( ll i = 0; i < n; ++i )
		ret *= x;

	return ret;
}

int main()
{
	scanf( "%lld", &N );

	if( N <= 25 )
	{ putchar( 'A'+N ); puts(""); return 0; }	

	N -= 26;

	ll t = N;
	while( t > 0 )
		ts.push_back( t%26 ), t /= 26;

	if( ts.size() >= 3 ) repd( i, ts.size()-1 ) if( i >= 2 )
		N -= powLL( 26, i );

	while( N > 0 )
		vs.push_back( N%26 ), N /= 26;

	while( vs.size() < 2 || vs.size() < ts.size() )
		vs.push_back( 0 );

	repd( i, vs.size()-1 )
		putchar( 'A'+vs[i] );

	puts("");

	return 0;
}
0