結果

問題 No.39 桁の数字を入れ替え
コンテスト
ユーザー tottoripaper
提出日時 2014-11-24 06:07:43
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 411 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,102 ms
コンパイル使用メモリ 166,884 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 15:58:46
合計ジャッジ時間 1,896 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s", ds);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstring>
#include <algorithm>

char ds[10];

int main(){
    scanf("%s", ds);
    
    int l = strlen(ds);

    int res = std::stoi(ds);
    for(int i=0;i<l;i++){
        for(int j=i+1;j<l;j++){
            std::swap(ds[i], ds[j]);
            res = std::max(res, std::stoi(ds));
            std::swap(ds[i], ds[j]);
        }
    }

    printf("%d\n", res);
}
0