結果
| 問題 |
No.3157 Nabeatsu
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-24 17:06:43 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 3,972 ms |
| コンパイル使用メモリ | 277,960 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-05-24 17:06:50 |
| 合計ジャッジ時間 | 5,498 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 WA * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
bool is_th(string N){
ll s=0;
for(auto n:N)s+=(n-'0');
return s%3==0;
}
void sub(string &N){
int SN=N.size();
for(int i=SN-1;i>=0;i--){
if(N[i]!='0'){
N[i]--;
for(int j=i+1;j<SN;j++){
N[i]='9';
}
return;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string N;
cin>>N;
ll SN=N.size();
for(int i=0;i<SN;i++){
if(N[i]=='3'){
N[i]='2';
for(int j=i+1;j<SN;j++){
N[j]='9';
}
break;
}
}
while(is_th(N)){
sub(N);
}
cout<<N<<endl;
}