結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
![]() |
提出日時 | 2025-05-23 19:36:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 928 bytes |
コンパイル時間 | 2,994 ms |
コンパイル使用メモリ | 275,880 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-23 19:36:11 |
合計ジャッジ時間 | 5,064 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(a) (a).begin(), (a).end() using ll = long long; const ll INF32 = 2e9; const ll INF64 = 4e18; void printYN(bool ok){ if(ok)cout << "Yes" << endl; else cout << "No" << endl; return; } int main() { string N; cin >> N; bool ok = false; while(!ok){ int cnt = 0; rep(i, N.size()){ if(N[i]=='3'){ N[i] = '2'; while(i<N.size()-1){ i++; N[i] = '9'; } } } rep(i, N.size())cnt+= N[i]-'0'; if(cnt%3)ok = true; else { int i = N.size()-1; while(N[i]=='0'){ N[i] = '9'; i--; } N[i]--; } } cout << N << endl; return 0; }