結果

問題 No.327 アルファベット列
ユーザー naimonon77naimonon77
提出日時 2016-09-22 14:12:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,698 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 174,036 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 18:25:51
合計ジャッジ時間 3,190 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 WA -
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
bool test = true;
#else 
bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

template<class T>
T pow(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

string mode0(ll N) {
	int i;
	string s = "A";
	rep(i, N) {
		int now = 0;
		while (1) {
			if (now == s.size()) {
				s.push_back('A');
				break;
			}
			else if (s[now] == 'Z') {
				s[now] = 'A';
				now++;
			}
			else {
				s[now]++;
				break;
			}
		}
	}
	reverse(ALL(s));
	return s;
}

const ll alphabet_num = 26;

string mode1(ll N) {
	int i;
	vector<ll> v;
  ll now = N;
	v.push_back(now % 26);
	now /= 26;
	while (1) {
		if (now == 0) break;
		ll value = now % 26 - 1;
		v.push_back(value);
		now /= 26;
	}

	string s;
	for(i=v.size()-1; i>-1; i--) {
		s.push_back((char)(v[i]+'A'));
	}
	return s;
	
	//ll sum = 0;
	//while (1) {
	//	if (N < sum) break;
	//	sum += pow((ll)26,now+1);
	//}
}

signed main(void) {
	int i, j, k, l;
	int mode = 1;
	function<string(ll)> f[] = { mode0,mode1 };
	string s;
	while (cin >> s) {
		if (isdigit(s[0])) {
			cout << f[mode](stoll(s)) << endl;
		}
		else if (s == "mode0") mode = 0;
		else if (s == "mode1") mode = 1;
	}
	return 0;
}
0