結果

問題 No.39 桁の数字を入れ替え
ユーザー TAKEKATSU
提出日時 2019-03-26 11:07:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 166,980 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 01:16:35
合計ジャッジ時間 2,589 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b)) * b;
}

int main(){
 
  string s; cin >> s;
  
  int initial = s[0] - '0';
  int pos = 0;

  for(int i = s.length() - 1; i > 0; i--)
  {
    int num = s[i] - '0';
    if(initial < num){
      initial = num;
      pos = i;
    }
  }

  for(int i = 0; i < s.length(); i++){
    
    if(pos == i)
      cout << s[0] - '0';
    else if(i == 0)
      cout << initial;
    else
      cout << s[i];
    
  }
  
  cout << endl;

  return 0;
}
0