結果
問題 | No.254 文字列の構成 |
ユーザー |
![]() |
提出日時 | 2021-05-04 17:38:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 3,172 ms |
コンパイル使用メモリ | 192,464 KB |
最終ジャッジ日時 | 2025-01-21 06:44:30 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
//https://ncode.syosetu.com/n4830bu/254/ #include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string ans; char c = 'a'; for (long long len = 1e5 + 1; len >= 1; len -= 2) { long long maine = (len + 1) * (len + 1) / 4; if (N >= maine) { N -= maine; for (int i = 0; i < len; i++) { ans += c + (i % 2); } c += 2; len += 2; } } cout << ans << endl; }