結果
問題 | No.736 約比 |
ユーザー |
|
提出日時 | 2019-04-26 21:04:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 903 bytes |
コンパイル時間 | 3,621 ms |
コンパイル使用メモリ | 77,088 KB |
実行使用メモリ | 54,380 KB |
最終ジャッジ日時 | 2024-11-25 01:04:35 |
合計ジャッジ時間 | 13,258 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 65 |
ソースコード
import java.io.*;import java.util.Scanner;public class Main_yukicoder736 {private static Scanner sc;private static Printer pr;private static void solve() {int n = sc.nextInt();long[] a = new long[n];for (int i = 0; i < n; i++) {a[i] = sc.nextLong();}long gcd = a[0];for (int i = 1; i < n; i++) {gcd = gcd(gcd, a[i]);}for (int i = 0; i < n; i++) {if (i > 0) {pr.print(':');}pr.print(a[i] / gcd);}pr.println();}static long gcd(long n, long m) {if (m == 0) {return n;} else {return gcd(m, n % m);}}// ---------------------------------------------------public static void main(String[] args) {sc = new Scanner(System.in);pr = new Printer(System.out);solve();pr.close();sc.close();}static class Printer extends PrintWriter {Printer(OutputStream out) {super(out);}}}