結果
問題 |
No.3299 K-th MMA String
|
ユーザー |
![]() |
提出日時 | 2025-10-09 16:49:29 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 990 bytes |
コンパイル時間 | 3,547 ms |
コンパイル使用メモリ | 280,896 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-09 16:49:34 |
合計ジャッジ時間 | 4,572 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/modint> using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* Kが小さい。 Nが大きくてもほとんどAAAAAA....AAAA(何か) みたいな形になる。 A->0 M->1のような2進数を考え、110が含まれるものを10^5個列挙する。 */ ll N, K; cin >> N >> K; vector<ll> v; auto check=[](ll x)->bool{ for (int i=0; i<30; i++){ if ((x / (1LL<<i)) % 8 == 6) return 1; } return 0; }; ll c=1; while(v.size() < K){ if (check(c)) v.push_back(c); c++; } string ans=""; while(v[K-1]){ ans += ((v[K-1] & 1) ? 'M' : 'A'); v[K-1] >>= 1; } while(ans.size() < N) ans += 'A'; reverse(ans.begin(), ans.end()); cout << ans << endl; return 0; }