結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
|
提出日時 | 2025-05-23 21:03:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 1,942 ms |
コンパイル使用メモリ | 193,212 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-23 21:03:52 |
合計ジャッジ時間 | 4,415 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; while(true){ bool ok = false; for(auto &c : s){ if(ok) c = '9'; else if(c == '3') ok = true,c--; } int sum = 0; for(auto c : s) sum += c-'0'; if(sum%3) break; for(int i=s.size(); i--;){ if(s.at(i) == '0') s.at(i) = '9'; else{s.at(i)--; break;} } } while(s.size() && s.at(0) == '0') s.erase(s.begin()); cout << s << endl; }