結果

問題 No.293 4>7の世界
ユーザー te-sh
提出日時 2017-06-08 17:49:24
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 137,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 19:49:47
合計ジャッジ時間 2,011 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split, a = rd[0], b = rd[1];

  writeln(calc(a, b) ? a : b);
}

auto calc(string a, string b)
{
  if (a.length != b.length)
    return a.length > b.length;

  foreach (ca, cb; lockstep(a, b)) {
    if (ca == '4' && cb == '7')
      return true;
    else if (ca == '7' && cb == '4')
      return false;
    else if (ca != cb)
      return ca > cb;
  }

  return true;
}
0