結果

問題 No.1883 SLASH
ユーザー uxux
提出日時 2023-02-02 17:45:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,236 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 203,496 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 23:17:23
合計ジャッジ時間 2,989 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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