結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
![]() |
提出日時 | 2025-05-26 00:28:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 883 bytes |
コンパイル時間 | 3,391 ms |
コンパイル使用メモリ | 278,332 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-26 00:29:02 |
合計ジャッジ時間 | 6,196 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; inline bool f(string s) { int digsum = 0; for (char c : s) { if (c == '3') return true; digsum += c - '0'; } return digsum % 3 == 0; } int main() { cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; while (f(s)) { if (s.contains('3')) { bool flg = false; rep(i, s.size()) { if (flg) s[i] = '9'; if (s[i] == '3') s[i] = '2', flg = true; } } else { for (int i = s.size() - 1; i >= 0; --i) { if (s[i] == '0') { s[i] = '9'; } else { s[i]--; break; } } } } cout << s << '\n'; return 0; }