結果

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

ソースコード

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) {
    writeln("428571"[s]);
  } else {
    if ((k[$ - 1] - '0') & 1) {
      writeln(8);
    } else {
      writeln(7);
    }
  }

}

// 28,57,14 28,5714 2857,14
// 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