結果

問題 No.593 4進FizzBuzz
ユーザー te-shte-sh
提出日時 2017-11-10 22:32:01
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 94,736 KB
実行使用メモリ 7,648 KB
最終ジャッジ日時 2024-06-12 22:24:16
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto n = readln.chomp;
  auto s = n.dup;
  s.reverse();

  auto c3 = 0, c5 = 0;
  foreach (i, c; s) {
    auto m = cast(int)(c - '0');
    c3 += m;
    c5 += (i % 2 == 0 ? m : m*4);
  }

  if (c3 % 3 == 0 && c5 % 5 == 0)
    writeln("FizzBuzz");
  else if (c3 % 3 == 0)
    writeln("Fizz");
  else if (c5 % 5 == 0)
    writeln("Buzz");
  else
    writeln(n);
}
0