結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2020-02-11 00:52:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 603 bytes |
コンパイル時間 | 640 ms |
コンパイル使用メモリ | 81,672 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 07:12:36 |
合計ジャッジ時間 | 1,288 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <string> #include <cstdio> #include <algorithm> #include <map> #include <queue> #include <cstdlib> #include <cstdio> using namespace std; #define rep(i, n) for(int (i) = (0); (i) < (n); (i++)) using ll = long long; int main() { string n; cin >> n; ll ans = stoll(n); string s = n; for(int i = 0; i < s.size(); ++i){ for(int j = i; j < s.size(); ++j){ swap(s[i], s[j]); ll tmp = stoll(s); ans = max(ans, tmp); s = n; } } cout << ans << endl; }