結果
| 問題 |
No.2864 String of yuusaan
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-30 22:03:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 573 bytes |
| コンパイル時間 | 2,163 ms |
| コンパイル使用メモリ | 192,408 KB |
| 最終ジャッジ日時 | 2025-02-24 03:04:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll siz[30];
int mss;
string key = "yuusaan";
char calc(int L, ll K) {
if (L == 1) {
return key[K - 1];
}
int ans = 0;
while (1) {
ll w = (ans % 6 ? 1ll : siz[L - 1]);
K -= w;
if (K <= 0) {
K += w;
break;
}
ans ++;
}
if (ans % 6) {
return key[ans];
} else {
return calc(L - 1, K);
}
}
int main () {
ll N, K;
cin >> N >> K;
siz[0] = 1;
mss = 1;
while (siz[mss - 1] < K) {
siz[mss] = siz[mss - 1] * 2 + 5;
mss ++;
}
N = min(N, (ll)mss);
cout << calc(N, K) << endl;
}