結果
| 問題 | No.3157 Nabeatsu | 
| コンテスト | |
| ユーザー |  ha_chan | 
| 提出日時 | 2025-05-23 19:23:29 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 905 bytes | 
| コンパイル時間 | 2,164 ms | 
| コンパイル使用メモリ | 193,652 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-05-23 19:23:40 | 
| 合計ジャッジ時間 | 3,975 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 42 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
int main() {
  string s;cin>>s;
  int n=s.size();
  bool han=0;
  rep(i,n){
    if(s[i]=='3'){s[i]='2';
      han=1;
      for(int j=i+1;j<n;j++){s[j]='9';}
    }
  }
  if(han){
    int sum=0;
    rep(i,n){sum+=s[i]-'0';}
    if(sum%3==0){s[n-1]--;}
    cout<<s<<endl;
    return 0;
  }
  int sum=0;
  rep(i,n){sum+=s[i]-'0';}
  if(sum%3!=0){cout<<s<<endl;}
  else{
    for(int i=n-1;i>=0;i--){
      if(s[i]!='0'){s[i]--;cout<<s<<endl;return 0;}
      s[i]='9';
    }
  }
}
            
            
            
        