結果

問題 No.751 Frac #2
ユーザー te-shte-sh
提出日時 2018-11-16 12:43:05
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 94,388 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-03 21:16:00
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.numeric;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n1; readV(n1);
  int[] a; readA(n1, a);
  int n2; readV(n2);
  int[] b; readA(n2, b);

  struct F { long n, p; }

  auto c = F(1, 1);
  foreach (ai; a) c = F(c.n, c.p*ai);

  auto d = F(1, 1);
  foreach_reverse (bi; b) d = F(d.p*bi, d.n);

  auto e = F(c.n*d.p, c.p*d.n);
  if (e.p < 0) { e.n = -e.n; e.p = -e.p; }

  auto g = gcd(e.n.abs, e.p.abs);
  e.n /= g; e.p /= g;

  writeln(e.n, " ", e.p);
}
0