結果
問題 | No.784 「,(カンマ)」 |
ユーザー |
![]() |
提出日時 | 2020-08-22 13:07:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 876 bytes |
コンパイル時間 | 1,154 ms |
コンパイル使用メモリ | 95,116 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 07:14:00 |
合計ジャッジ時間 | 1,624 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <stack> #include <algorithm> #include <string> #include <map> #include <iterator> #include <set> #include <queue> #include <bitset> #include <cassert> using namespace std; string m(string S) { int N = S.size(); assert(N > 0); string res; if (N % 3 == 0) { res = S.substr(0, 3); for (int i = 0; i < N - 3; ++i) { if (i % 3 == 0) { res += ","; } res += S[i + 3]; } } else { res = S.substr(0, N % 3); for (int i = 0; i < N - (N % 3); ++i) { if (i % 3 == 0) { res += ","; } res += S[i + N % 3]; } } return res; } int main() { string S; cin >> S; cout << m(S) << endl; }