結果
問題 | No.2864 String of yuusaan |
ユーザー |
|
提出日時 | 2024-08-30 21:35:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 956 bytes |
コンパイル時間 | 1,949 ms |
コンパイル使用メモリ | 195,840 KB |
最終ジャッジ日時 | 2025-02-24 02:54:24 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long N,K; cin >> N >> K; string s = "yuusaan"; if(N == 1 || K <= 7){ cout << s.at(K-1) << endl; return 0; } vector<long long> len(50); long long add = 6,l = 1; for(int i=0; i<50; i++){ len.at(i) = l; l += add; add *= 2; } auto dfs = [&](auto dfs,int level,long long left,bool y = true) -> void { if(level == 0){ if(y) cout << "y" << endl; else cout << "n" << endl; return; } if(left > len.at(level-1)){ left -= len.at(level-1); if(left <= 5){ cout << s.at(left) << endl; return; } left -= 5; dfs(dfs,level-1,left,false); } else dfs(dfs,level-1,left,true); }; dfs(dfs,min(50LL,N),K); }