結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
![]() |
提出日時 | 2025-05-29 21:07:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 438 bytes |
コンパイル時間 | 944 ms |
コンパイル使用メモリ | 83,320 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-29 21:07:24 |
合計ジャッジ時間 | 5,149 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 3 |
ソースコード
#include<iostream> #include<vector> using namespace std; int main(){ string S;cin>>S; int N=S.size(); bool isFound = false; for(int i=0;i<N;++i){ if(isFound)S[i]='9'; else if(S[i]=='3'){ S[i]='2'; isFound = true; } } int sum = 0; for(int i=0;i<N;++i){ sum += S[i]-'0'; } if(sum%3){ cout << S << endl; } else { int idx=N-1; if(S[idx]=='0'){ S[idx]='9'; idx--; } S[idx]--; cout << S << endl; } }