結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
![]() |
提出日時 | 2025-05-23 19:30:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 1,560 bytes |
コンパイル時間 | 955 ms |
コンパイル使用メモリ | 112,436 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-23 19:30:50 |
合計ジャッジ時間 | 3,602 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <iostream> #include <iomanip>//小数点出力用 //cout << fixed << setprecision(10) << ans; #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <set> #include <unordered_set> #include <map> using ll = long long; using namespace std; #define modP7 1'000'000'007 #define modP 998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } bool include3(string S) { for (int i = 0;i < S.size();i++) { if (S[i] == 0x33) { return 1; } } return 0; } bool multi3(string S) { int res = 0; for (int i = 0;i < S.size();i++) { res += (int)(S[i] - 0x30); } if (res % 3 == 0) { return 1; } return 0; } int main() { string S; cin >> S; while (1) { if (include3(S)) { int f = S.find("3"); S[f] = '2'; for (int i = f + 1;i < S.size();i++) { S[i] = '9'; } continue; } if (multi3(S)) { for (int i = S.size() - 1;i >= 0;i--) { if (S[i] == '0') { S[i] = '9'; } else { S[i]--; break; } } continue; } break; } int j = 0; while (S[j] == '0')j++; for (;j < S.size();j++) { cout << S[j]; } return 0; }