結果

問題 No.751 Frac #2
ユーザー suikameron1suikameron1
提出日時 2018-11-09 23:26:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 1,165 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 103,316 KB
実行使用メモリ 22,900 KB
最終ジャッジ日時 2023-08-13 12:10:12
合計ジャッジ時間 5,906 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,680 KB
testcase_01 AC 59 ms
20,716 KB
testcase_02 AC 58 ms
20,756 KB
testcase_03 AC 58 ms
22,756 KB
testcase_04 AC 57 ms
20,624 KB
testcase_05 AC 58 ms
20,652 KB
testcase_06 AC 58 ms
20,660 KB
testcase_07 AC 57 ms
20,760 KB
testcase_08 AC 57 ms
20,704 KB
testcase_09 AC 59 ms
22,888 KB
testcase_10 AC 59 ms
20,676 KB
testcase_11 AC 58 ms
22,900 KB
testcase_12 AC 58 ms
22,756 KB
testcase_13 AC 59 ms
22,816 KB
testcase_14 AC 59 ms
20,712 KB
testcase_15 AC 58 ms
20,608 KB
testcase_16 AC 60 ms
20,704 KB
testcase_17 AC 59 ms
22,728 KB
testcase_18 AC 57 ms
22,680 KB
testcase_19 AC 58 ms
20,712 KB
testcase_20 AC 58 ms
20,656 KB
testcase_21 AC 59 ms
20,668 KB
testcase_22 AC 57 ms
20,624 KB
testcase_23 AC 57 ms
20,720 KB
testcase_24 AC 58 ms
20,668 KB
testcase_25 AC 59 ms
20,716 KB
testcase_26 AC 59 ms
22,756 KB
testcase_27 AC 59 ms
20,600 KB
testcase_28 AC 58 ms
20,720 KB
testcase_29 AC 58 ms
20,636 KB
testcase_30 AC 58 ms
22,752 KB
testcase_31 AC 58 ms
20,632 KB
testcase_32 AC 57 ms
20,680 KB
testcase_33 AC 58 ms
20,688 KB
testcase_34 AC 58 ms
20,828 KB
testcase_35 AC 58 ms
22,632 KB
testcase_36 AC 59 ms
22,688 KB
testcase_37 AC 59 ms
22,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = 1;

    for(int i = 1; i < nA; i++) mother *= numsA[i];
    for(int i = 0; i < nB; i++)
    {
      if(i % 2 == 0) mother *= numsB[i];
      else 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