結果

問題 No.747 循環小数N桁目 Hard
ユーザー ikd
提出日時 2018-10-19 22:48:25
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 94,080 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-13 01:53:53
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

  int s = 0;
  foreach (c; n) {
    s = (s * 10 + (c - '0')) % 6;
  }
  if (s == 2) {
    if ((k[$ - 1] - '0') & 1) {
      writeln(8);
    } else {
      writeln(7);
    }
  } else if (s == 5) {
    if ((k[$ - 1] - '0') & 1) {
      writeln(1);
    } else {
      writeln(2);
    }
  } else {
    writeln("428571"[s]);
  }

}

// 28,57,14 28,5714 2857,14 285714 285714 28,5714
// 2857,14 285714 2857,14

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}
0