結果
| 問題 |
No.327 アルファベット列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-09 12:33:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,138 bytes |
| コンパイル時間 | 1,770 ms |
| コンパイル使用メモリ | 172,140 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 16:10:56 |
| 合計ジャッジ時間 | 3,808 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2(i, n, s) for (int i = (n - 1); i >= (s); i--)
#define all(a) (a).begin(),(a).end()
#define all_c(a, b) (a).begin(), (a).end(), back_inserter((b))
vector<int> dy = {-1, 0, 1, 0, -1, -1, 1, 1};
vector<int> dx = {0, 1, 0, -1, -1, 1, 1, -1};
const ll INF = numeric_limits<long long>::max();
const ll MOD = 1'000'000'007;
ll unused = INF % MOD;
ll gcd(ll A, ll B) {
if (B == 0) return A;
return gcd(B, A % B);
}
ll lcm(ll A, ll B) {
ll g = gcd(A, B);
return A / g * B;
}
// 二分検索の雛型
bool binary_search(int N, int A[], int K) {
int left = 0, right = N - 1;
while (left <= right) {
int mid = (left + right) / 2;
if (A[mid] == K) return true;
if (A[mid] < K) left = mid + 1;
else right = mid - 1;
}
return false;
}
/*
lower_bound -> if (A[mid] < K)
upper_bound -> if (A[mid] <= K)
*/
int binary_search2(int N, ll A[], ll K) {
int left = 0, right = N;
while (left < right) {
int mid = (left + right) / 2;
if (A[mid] < K) left = mid + 1;
else right = mid;
}
return right;
}
/* メモ帳
・小数点以下表示 / cout << fixed << setprecision(12) <<
・ルートの計算 / sqrt(A)
・順列全列挙
do {
} while (next_permutation(V.begin() V.end()));
・bit検索
for (int i = 0; i < (1 << N); i++) {
rep(j, 0, N) {
int wari = (1 << j);
if ((i / wari) % 2 == 1) {
}
}
}
*/
ll N, tmp = 1ll, n;
vector<ll> V;
string S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ans = "";
// 01234567890123456789012345
int main() {
cin >> N;
if (N == 0) {
cout << "A\n";
return 0;
}
while (tmp <= N) {
V.push_back(tmp);
tmp *= 26;
}
reverse(all(V));
rep(i, 0, V.size()) {
if (ans == "" && N / V[i] == 0) continue;
if (i != V.size() - 1) ans += S[N / V[i] - 1];
else ans += S[N / V[i]];
N %= V[i];
}
cout << ans << endl;
}