結果
問題 | No.327 アルファベット列 |
ユーザー |
![]() |
提出日時 | 2016-02-10 18:42:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,734 bytes |
コンパイル時間 | 1,639 ms |
コンパイル使用メモリ | 161,128 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 23:00:44 |
合計ジャッジ時間 | 2,995 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;typedef pair<ll, ll> P;#define EACH(i,a) for (auto& i : a)#define FOR(i,a,b) for (ll i=(a);i<(b);i++)#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)#define REP(i,n) for (ll i=0;i<(n);i++)#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)#define debug(x) cout<<#x<<": "<<x<<endl#define pb push_back#define ALL(a) (a).begin(),(a).end()const ll linf = 1e18;const int inf = 1e9;const double eps = 1e-12;const double pi = acos(-1);template<typename T>istream& operator>>(istream& is, vector<T>& vec) {EACH(x,vec) is >> x;return is;}/*template<class... T>ostream& operator<<(ostream& os, tuple<T...>& t) {for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {if (i) os << " ";os << get<0>(t);}return os;}*/template<typename T>ostream& operator<<(ostream& os, vector<T>& vec) {REP(i,vec.size()) {if (i) os << " ";os << vec[i];}return os;}template<typename T>ostream& operator<<(ostream& os, vector< vector<T> >& vec) {REP(i,vec.size()) {if (i) os << endl;os << vec[i];}return os;}ll power(ll x, ll n) {ll res = 1;for (ll i = 1; i <= n; i <<= 1) {if (n & i) {res *= x;}x *= x;}return res;}ll S(ll n) {if (n < 0) return 0;return (power(26, n)-1)/25*26;}int main() {std::ios::sync_with_stdio(false);std::cin.tie(0);ll N; cin >> N;ll l = 12;REP(i, 12) {if ( S(i) > N ) {l = i;break;}}N -= S(l-1);// cout << l << " " << S(l-1) << " " << N << endl;vector<int> v;REP(i, l) {v.pb(N % 26);N /= 26;}reverse( ALL(v) );REP(i, l) {cout << (char)(v[i]+'A');}cout << endl;}