結果

問題 No.751 Frac #2
ユーザー suikameron1suikameron1
提出日時 2018-11-09 23:20:30
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,108 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 105,912 KB
実行使用メモリ 24,824 KB
最終ジャッジ日時 2023-08-13 12:09:49
合計ジャッジ時間 5,966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,748 KB
testcase_01 AC 57 ms
22,788 KB
testcase_02 WA -
testcase_03 AC 56 ms
20,700 KB
testcase_04 AC 55 ms
20,708 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 56 ms
20,644 KB
testcase_08 WA -
testcase_09 AC 57 ms
20,744 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 56 ms
20,604 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 56 ms
22,700 KB
testcase_19 AC 56 ms
20,752 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 58 ms
18,780 KB
testcase_33 AC 57 ms
22,704 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long nA = long.Parse(Console.ReadLine());
		long[] numsA = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long nB = long.Parse(Console.ReadLine());
		long[] numsB = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long child = numsA[0];
    long mother = numsB[0];

    for(int i = 1; i < nA; i++) mother *= numsA[i];
    for(int i = 1; i < nB; i++) child *= numsB[i];

    long gcd = Gcd(mother, child);

    child /= gcd;
    mother /= gcd;
    if(mother < 0)
    {
      child *= -1;
      mother *= -1;
    }
    
		Console.WriteLine(child + " " + mother);
	}

  static long Gcd(long a, long b) 
      {//引数a,bの最大公約数を返す
           if (a < b)
               return Gcd(b, a);//入れ替え
           while (b != 0) 
           {
               long changeTo = a % b;
               a = b;
               b = changeTo;
           }
           return a;
       }
  
}
0