結果
| 問題 |
No.736 約比
|
| コンテスト | |
| ユーザー |
suikameron1
|
| 提出日時 | 2018-11-10 12:38:45 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 1,936 ms |
| コンパイル使用メモリ | 104,064 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-11-24 03:56:10 |
| 合計ジャッジ時間 | 4,240 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static void Main()
{
long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
long gcd = nums[0];
for(int i = 1; i < n; i++) gcd = Gcd(gcd, nums[i]);
for(int i = 0; i < n; i++) nums[i] /= gcd;
Console.WriteLine(string.Join(":", nums));
}
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;
}
}
suikameron1