結果
| 問題 |
No.327 アルファベット列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-22 14:11:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,697 bytes |
| コンパイル時間 | 1,790 ms |
| コンパイル使用メモリ | 173,008 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 13:08:06 |
| 合計ジャッジ時間 | 6,947 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 3 RE * 31 |
ソースコード
#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](stoi(s)) << endl;
}
else if (s == "mode0") mode = 0;
else if (s == "mode1") mode = 1;
}
return 0;
}