結果

問題 No.1883 SLASH
ユーザー ux
提出日時 2023-02-02 17:45:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,236 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 197,760 KB
最終ジャッジ日時 2025-02-10 08:14:52
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 11 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>    //atcoder
//using namespace atcoder;  //atcoder
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<long long>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vd = vector<double>;
using vld = vector<long double>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvd = vector<vector<double>>;
using vvld = vector<vector<long double>>;
// Graph
using Graph = vector<vector<int>>;
using Nodes = pair<int,int>;
//using pri = priority_queue<ll>;  //最大値
//using pri = priority_queue<ll, vector<ll>, greater<ll>>;   //最小値
#define _GLIBCXX_DEBUG
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
const int INF = 1e9;
const int MININF = -1e9;
const ll LINF = 1e18;
const ll MINLINF = -1e18;
const int MOD = 1e9+7;
const int MODD = 998244353;

// 4方向
vi vx={0, 1, 0, -1};
vi vy={1, 0, -1, 0};


// a<bならaをbに更新
template <class T>
bool chmax(T &a, const T& b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

// a>bならaをbに更新
template <typename T>
bool chmin(T &a, const T& b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}

// NのK乗をMで割った余り
ll power(ll N, ll K, ll M){
    if(K == 0)return 1;
    else if(K%2 == 1){
        return power(N, K-1, M) * N % M;
    }
    else{
        ll T = power(N, K/2, M);
        return T * T % M;
    }
}


int M(int N){
    int ans=0;
    while(N>0){
        chmax(ans,N%10);
        N/=10;
    }
    return ans;
}

int m(int N){
    int ans=1000;
    while(N>0){
        chmin(ans,N%10);
        N/=10;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin>>N;

    cout<<M(N)-m(N)<<endl;
}
0