結果
問題 | No.2198 Concon Substrings (COuNt-CONstruct Version) |
ユーザー |
![]() |
提出日時 | 2023-01-20 22:55:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 977 ms |
コンパイル使用メモリ | 97,076 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 10:54:30 |
合計ジャッジ時間 | 4,621 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 104 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <queue>#include <deque>#include <cmath>#include <iomanip>#include <set>#include <map>#include <cassert>using namespace std;using ll = long long;using ld = long double;int main(){ll m; cin >> m;auto f = [](ll x){return x*(x+1)/2*(x+2)/3;};auto g = [](ll x){return x*(x+1)/2;};ll x1 = 1, wa = 20000;while(wa-x1 > 1){ll wj = (x1+wa)/2;if(f(wj) <= m) x1 = wj;else wa = wj;}ll m1 = m-f(x1);auto h = [&](ll m1, ll x){vector<ll> res;for(; x > 0; x--){res.emplace_back(m1/g(x));m1 %= g(x);}return res;};auto v = h(m1, x1);// cerr << v.size() << " " << x1 << endl;reverse(v.begin(), v.end());string ans = "";for(int i = 0; i < x1; i++){ans += "con";for(int j = 0; j < v[i]; j++) ans += "n";}assert(ans.size() <= 60000);if(m == 0) ans = "hitachi";cout << ans << endl;return 0;}