結果

問題 No.293 4>7の世界
ユーザー kichirb3
提出日時 2018-03-28 17:06:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,254 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 68,480 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 12:37:09
合計ジャッジ時間 1,501 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.293 4>7の世界
// https://yukicoder.me/problems/no/293
// 

#include <iostream>
#include <string>
#include <cmath>
using namespace std;


class number {
public:
    string val;

    bool operator<(number other) {
        if (val.size() > other.val.size())
            return false;
        if (val.size() < other.val.size())
            return true;
        for (auto i = 0; i < val.size(); ++i) {
            if (val[i] != other.val[i]) {
                if (val[i] == '4' && other.val[i] == '7' || val[i] == '7' && other.val[i] == '4')
                    return !(val[i] < other.val[i]);
                else
                    return val[i] < other.val[i];
            }
        }
        return false;
    }
};

template<typename CharT, typename Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, number& s) {
    os << s.val;
    return os;
}

template<typename CharT, typename Traits>
basic_istream<CharT, Traits>&
operator>>(basic_istream<CharT, Traits>& is, number& s) {
    is >> s.val;
    return is;
};


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

    number A, B;
    cin >> A >> B;

    if (A < B)
        cout << B << endl;
    else
        cout << A << endl;
}
0