結果

問題 No.544 Delete 7
ユーザー te-sh
提出日時 2017-07-14 22:32:14
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 996 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 115,456 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 20:56:07
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container; // SList, DList, BinaryHeap
import std.typecons;  // Tuple, Nullable, BigFlags
import std.math;      // math functions
import std.numeric;   // gcd, fft
import std.bigint;    // BigInt
import std.random;    // random
import std.bitmanip;  // BitArray
import core.bitop;    // bit operation
import std.regex;     // RegEx
import std.uni;       // unicode

void main()
{
  auto n = readln.chomp.to!int;
  auto a = n.toArray;

  auto b = a.dup, c = a.dup;
  foreach (i; 0..a.length)
    if (a[i] == 7) {
      b[i] = 3;
      c[i] = 4;
    } else if (a[i] == 8) {
      b[i] -= 2;
      c[i] = 2;
    } else if (a[i] > 0) {
      b[i] -= 1;
      c[i] = 1;
    }

  writeln(b.toInt, " ", c.toInt);
}

auto toArray(int n)
{
  int[] r;
  if (n == 0) return [0];
  for (; n > 0; n /= 10)
    r = (n % 10) ~ r;
  return r;
}

auto toInt(int[] a)
{
  auto r = 0;
  foreach (ai; a)
    r = r * 10 + ai;
  return r;
}
0