結果
| 問題 | No.736 約比 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-06 14:45:56 |
| 言語 | Java (openjdk 25.0.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,863 bytes |
| 記録 | |
| コンパイル時間 | 4,184 ms |
| コンパイル使用メモリ | 79,264 KB |
| 実行使用メモリ | 53,976 KB |
| 最終ジャッジ日時 | 2024-07-18 13:56:37 |
| 合計ジャッジ時間 | 14,238 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 64 WA * 1 |
ソースコード
import java.util.*;
import java.io.*;
import java.math.*;
public class No736 {
public static void main(String[] args) {
try {
// 入力元がファイルの場合
// Scanner sc = new Scanner(new File("/Users/aa352872/Desktop/test"));
// 入力元が標準入力の場合
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long a[] = new long[n];
for(int i = 0; i < n; i++) {
a[i] = sc.nextLong();
}
long max = 1;
for(int i = n-1; i > 0; i--) {
long si = a[i];
long bo = a[i - 1];
long ama = -1;
while(ama != 0) {
ama = si % bo;
// System.out.println("分子 = " + si + " 分母 = " + bo + " 余り = " + ama);
if(ama == 0) {
break;
}else {
si = bo;
bo = ama;
}
};
if(max == 1) {
max = bo;
// System.out.println("max = " + max + " a[" + i + "] = " + a[i]);
}else if(max < bo) {
// System.out.println("coco1");
if(bo % max == 0) {
// nothing
}else {
max = 1;
break;
}
}else if(max > bo) {
// System.out.println("coco2");
max = bo;
// if(max % bo == 0) {
// max = bo;
// }else {
// max = 1;
// break;
// }
}
}
for(int i = 1; i < n; i++) {
if(a[i]%max != 0) {
max = 1;
}
}
// System.out.println("last max = " + max);
// System.out.println("max = " + max);
System.out.print(a[0]/max);
for(int i = 1; i < n; i++) {
System.out.print(":" + a[i]/max);
}
System.out.println("");
}catch (Exception e) {
System.out.println("例外が発生しました。");
System.out.println(e);
return;
}
}
}