結果

問題 No.593 4進FizzBuzz
ユーザー ikdikd
提出日時 2017-11-11 15:20:31
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 79,324 KB
実行使用メモリ 8,464 KB
最終ジャッジ日時 2023-09-03 16:51:27
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 13 ms
7,300 KB
testcase_17 AC 13 ms
6,864 KB
testcase_18 AC 12 ms
6,928 KB
testcase_19 AC 18 ms
6,876 KB
testcase_20 AC 13 ms
7,488 KB
testcase_21 AC 12 ms
6,848 KB
testcase_22 AC 19 ms
7,716 KB
testcase_23 AC 14 ms
7,512 KB
testcase_24 AC 14 ms
7,720 KB
testcase_25 AC 14 ms
7,432 KB
testcase_26 AC 19 ms
6,460 KB
testcase_27 AC 19 ms
8,148 KB
testcase_28 AC 14 ms
8,020 KB
testcase_29 AC 18 ms
6,812 KB
testcase_30 AC 14 ms
7,476 KB
testcase_31 AC 14 ms
7,492 KB
testcase_32 AC 13 ms
7,424 KB
testcase_33 AC 18 ms
6,996 KB
testcase_34 AC 14 ms
8,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
  1%3  = 1
  4%3  = 1
  16%3 = 1
  64%3 = 1
  ...
  (4^n)%3 = 1 ?

  1%5  = 1
  4%5  = 4
  16%5 = 1
  ...
  even: 1
  odd : 4
  
*/

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto n=readln.chomp.to!(char[]);
  reverse(n);

  int sum1=0, sum2=0;
  foreach(i, e; n){
    int d=e-'0';
    sum1+=d;
    int md=i&1 ? 4 : 1;
    sum2+=md*d;
  }

  bool fiz=(sum1%3==0);
  bool buz=(sum2%10==0 || sum2%10==5);
  if(fiz && buz){
    writeln("FizzBuzz");
  }else if(fiz){
    writeln("Fizz");
  }else if(buz){
    writeln("Buzz");
  }else{
    reverse(n);
    writeln(n);
  }

}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
0