結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
こっとん
|
| 提出日時 | 2026-08-30 16:47:19 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,035 bytes |
| 記録 | |
| コンパイル時間 | 2,990 ms |
| コンパイル使用メモリ | 353,252 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-08-30 16:47:30 |
| 合計ジャッジ時間 | 5,580 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 14 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/dsu>
// #include<atcoder/modint>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<< "Yes"<< endl
#define NO cout<< "No"<< endl
#define Rep(i,s,n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
template<class T, class U> bool chmax(T& x, const U& y){
if (x < y) { x = y; return true; }
return false;
}
template<class T, class U> bool chmin(T& x, const U& y){
if (y < x) { x = y; return true; }
return false;
}
#define UNIQUE(a) a.erase(unique(a.begin(),a.end()),a.end())
using namespace std;
// using mint = atcoder::modint998244353;
// using mint2 = atcoder::modint1000000007;
// using namespace atcoder;
using ll = long long;
using V = vector<ll>;
using P = pair<ll,ll>;
using i128 = __int128;
void solve(){
string n; cin >> n;
int d = n.size();
int u = -1;
int uf = -1;
rep(i,d){
if(n[i]-'0' < 4) {
u = i;
break;
}
}
if(u != -1){
rep(i,u)if(n[i] == '5') uf = i;
}
string ans = "";
bool five = false;
//d-1桁の場合
if(u != -1 && uf == -1){
rep(i,d-1) cout << 5;
cout << endl;
return;
}
if(u != -1 && uf != -1){
rep(i,uf) cout << n[i];
cout << 4;
rep(i,d-uf-1) cout << 5;
return;
}
rep(i,d){
if(n[i]-'0' > 5){
rep(k,d-i)ans.push_back('5');
break;
}
// if(i && u-1 == i){
// ans.push_back('4');
// rep(k,d-i-1)ans.push_back('5');
// break;
// }
if(uf == i){
ans.push_back('4');
rep(k,d-i-1) ans.push_back('5');
break;
}
if(n[i] == '5') ans.push_back('5');
if(n[i] == '4') ans.push_back('4');
}
cout << ans << endl;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
t = 1;
//cin >> t;
rep(i,t) solve();
}
こっとん