結果

問題 No.39 桁の数字を入れ替え
ユーザー mmn15277198mmn15277198
提出日時 2021-04-10 21:48:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,371 bytes
コンパイル時間 957 ms
コンパイル使用メモリ 89,432 KB
実行使用メモリ 7,384 KB
最終ジャッジ日時 2023-09-08 17:28:53
合計ジャッジ時間 1,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,048 KB
testcase_01 AC 5 ms
7,308 KB
testcase_02 AC 5 ms
7,320 KB
testcase_03 AC 5 ms
7,236 KB
testcase_04 AC 5 ms
7,052 KB
testcase_05 AC 5 ms
7,156 KB
testcase_06 WA -
testcase_07 AC 5 ms
7,152 KB
testcase_08 WA -
testcase_09 AC 4 ms
7,236 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 5 ms
7,044 KB
testcase_15 AC 5 ms
7,108 KB
testcase_16 AC 4 ms
7,060 KB
testcase_17 AC 5 ms
7,172 KB
testcase_18 AC 5 ms
7,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <iomanip>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define vi vector<int>
#define vll vector<long long>
#define all(x) x.begin() , x.end()
#define pb push_back()
#define eb emplace_back()


typedef long long ll;
typedef long double ld;

//const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ld PI = 3.14159265358979;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int MX = 220000;

ll gcd (ll a , ll b) { if (a < b) swap(a , b); if (a % b == 0) return b; else return gcd(b , a % b); }
ll lcm (ll a , ll b) { return a / gcd(a , b) * b; }
ll lin() { ll x; scanf("%lld" , &x); return x; }
int in() { int x; scanf("%d" , &x); return x; }

void io_setup() {
    cout << fixed << setprecision(20);
}

ll modpow (ll x , ll p) {
    ll ret = 1;
    while (p) {
        if (p % 2 == 1) {
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        p /= 2;
    }
    return ret;
}

ll moddiv (ll a , ll b) {
    return a * modpow(b , MOD - 2) % MOD;
}

ll modsub (ll a , ll b) {
    if (a >= b) return (a - b) % MOD;
    else return (MOD - a + b);
}

vll fact(MX);
vll factinv(MX);
void init_fact () {
    fact[0] = 1;
    for (int i = 1; i < MX; i++) {
        fact[i] = fact[i] * fact[i - 1] % MOD;
    }
    for (int i = 0; i < MX; i++) {
        factinv[i] = modpow(fact[i] , MOD - 2);
    }
}

ll nCk (ll n , ll k) {
    return ((fact[n] * factinv[k] % MOD) * factinv[n - k] % MOD);
}

bool is_prime (int x) {
    if (x == 2 || x == 3 || x == 5 || x == 7) {
        return true;
    }
    for (ll i = 2; i*i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

vi prime(MX , 0);
void init_prime() {
    
}


int main() {
    io_setup();
    //init_fact();
    string s;
    cin >> s;
    int mx = -1 , mi = INF;
    int mxi = 0 , mii = 0;
    int n = s.size();
    rep(i,n) {
        int now = s[i] - '0';
        if (mx <= now) {
            mx = now;
            mxi = i;
        }
        if (mi > now) {
            mi = now;
            mii = i;
        }
    }
    swap(s[mxi] , s[mii]);
    cout << s << endl;
    return 0;
}




0