結果
| 問題 |
No.736 約比
|
| コンテスト | |
| ユーザー |
ekidenp
|
| 提出日時 | 2018-09-28 22:20:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 622 bytes |
| コンパイル時間 | 1,354 ms |
| コンパイル使用メモリ | 104,192 KB |
| 実行使用メモリ | 18,176 KB |
| 最終ジャッジ日時 | 2024-10-12 06:45:31 |
| 合計ジャッジ時間 | 4,320 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.Collections.Generic;
class Program
{
static void Main(string[] args)
{
long N = long.Parse(Console.ReadLine());
string[]str = Console.ReadLine().Split();
long[] A = new long[N];
for(var i=0;i<N;i++){
A[i] = long.Parse(str[i]);
}
long B = Gcd(A[0],A[1]);
for(var i=2;i<N;i++){
B = Gcd(B,A[i]);
}
string ans = "";
ans += "" + A[0]/B;
for(var i=1;i<N;i++){
ans += ":" + A[i]/B;
}
Console.WriteLine(ans);
}
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
}
ekidenp