結果

問題 No.327 アルファベット列
ユーザー airuai
提出日時 2016-09-23 10:15:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 60,500 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 17:34:07
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define pr(s) std::cout << s << std::endl
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	vector<char> c;
	vector<char>::iterator it = c.begin();
	c.insert(it, n % 26 + 'A');
	it = c.begin();
	n /= 26;
	int t;
	bool up = false;
	while (n) {
		t = n % 26;
		if (up) {
			if (t > 1) {
				c.insert(it, t + 'A' - 2);
				up = false;
			}
			else if (t == 1){
				c.insert(it, 'Z');
			}
			else {
				c.insert(it, 'Y');
			}
		}
		else {
			if (t == 0) {
				c.insert(it, 'Z');
				up = true;
			}
			else {
				c.insert(it, t + 'A' - 1);
			}
		}
		it = c.begin();
		n /= 26;
	}
	if (up) {
		++it;
	}
	while (it != c.end()) {
		cout << *it;
		++it;
	}
	cout << endl;
}
0