結果
| 問題 | No.39 桁の数字を入れ替え |
| コンテスト | |
| ユーザー |
DaYuanChi
|
| 提出日時 | 2021-01-26 00:17:01 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| + 470µs | |
| コード長 | 436 bytes |
| 記録 | |
| コンパイル時間 | 938 ms |
| コンパイル使用メモリ | 181,360 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-27 11:44:59 |
| 合計ジャッジ時間 | 2,293 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
string s; cin >> s;
int n = s.size();
int ans = stoi(s);
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
int now = 0;
swap(s[i], s[j]);
for(int i = 0; i < n; i++){
now += (s[i]-'0')*pow(10,n-1-i);
ans = max(ans, now);
}
swap(s[i], s[j]);
}
}
cout << ans << endl;
return 0;
}
DaYuanChi