結果

問題 No.736 約比
ユーザー tsunabittsunabit
提出日時 2019-08-06 14:45:56
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,863 bytes
コンパイル時間 6,405 ms
コンパイル使用メモリ 76,180 KB
実行使用メモリ 57,964 KB
最終ジャッジ日時 2023-09-25 17:45:24
合計ジャッジ時間 20,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
55,660 KB
testcase_01 AC 148 ms
56,284 KB
testcase_02 AC 153 ms
55,676 KB
testcase_03 AC 159 ms
55,748 KB
testcase_04 AC 160 ms
56,296 KB
testcase_05 AC 146 ms
55,744 KB
testcase_06 AC 138 ms
55,804 KB
testcase_07 AC 159 ms
55,524 KB
testcase_08 AC 157 ms
55,664 KB
testcase_09 AC 154 ms
55,644 KB
testcase_10 AC 155 ms
55,824 KB
testcase_11 AC 159 ms
56,212 KB
testcase_12 AC 157 ms
55,516 KB
testcase_13 AC 158 ms
56,216 KB
testcase_14 AC 148 ms
56,384 KB
testcase_15 AC 163 ms
55,644 KB
testcase_16 AC 148 ms
56,076 KB
testcase_17 AC 160 ms
56,048 KB
testcase_18 AC 157 ms
55,980 KB
testcase_19 AC 154 ms
56,128 KB
testcase_20 AC 158 ms
55,972 KB
testcase_21 AC 157 ms
55,648 KB
testcase_22 AC 144 ms
55,752 KB
testcase_23 AC 139 ms
55,728 KB
testcase_24 AC 160 ms
55,936 KB
testcase_25 AC 143 ms
55,812 KB
testcase_26 AC 142 ms
56,016 KB
testcase_27 AC 163 ms
56,052 KB
testcase_28 AC 159 ms
55,788 KB
testcase_29 AC 137 ms
55,684 KB
testcase_30 AC 160 ms
55,680 KB
testcase_31 AC 139 ms
56,028 KB
testcase_32 AC 139 ms
55,976 KB
testcase_33 AC 159 ms
56,136 KB
testcase_34 AC 139 ms
56,056 KB
testcase_35 AC 138 ms
55,488 KB
testcase_36 AC 160 ms
55,972 KB
testcase_37 AC 162 ms
56,296 KB
testcase_38 AC 161 ms
56,044 KB
testcase_39 AC 139 ms
56,132 KB
testcase_40 AC 158 ms
57,964 KB
testcase_41 AC 156 ms
55,896 KB
testcase_42 AC 159 ms
55,828 KB
testcase_43 AC 160 ms
56,472 KB
testcase_44 AC 157 ms
55,932 KB
testcase_45 AC 160 ms
56,116 KB
testcase_46 AC 140 ms
55,916 KB
testcase_47 WA -
testcase_48 AC 151 ms
55,692 KB
testcase_49 AC 144 ms
55,712 KB
testcase_50 AC 149 ms
55,664 KB
testcase_51 AC 147 ms
55,748 KB
testcase_52 AC 159 ms
55,892 KB
testcase_53 AC 154 ms
55,832 KB
testcase_54 AC 157 ms
55,876 KB
testcase_55 AC 146 ms
56,264 KB
testcase_56 AC 151 ms
56,024 KB
testcase_57 AC 143 ms
56,240 KB
testcase_58 AC 166 ms
56,216 KB
testcase_59 AC 162 ms
56,260 KB
testcase_60 AC 146 ms
55,956 KB
testcase_61 AC 160 ms
55,884 KB
testcase_62 AC 141 ms
56,208 KB
testcase_63 AC 139 ms
55,912 KB
testcase_64 AC 142 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
    	}
    }
}
0