結果

問題 No.736 約比
ユーザー tsunabittsunabit
提出日時 2019-08-05 18:44:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 4,484 ms
コンパイル使用メモリ 84,892 KB
実行使用メモリ 58,132 KB
最終ジャッジ日時 2023-09-25 17:25:31
合計ジャッジ時間 18,580 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
55,800 KB
testcase_01 WA -
testcase_02 AC 148 ms
55,724 KB
testcase_03 AC 154 ms
55,964 KB
testcase_04 AC 157 ms
56,236 KB
testcase_05 AC 141 ms
56,496 KB
testcase_06 WA -
testcase_07 AC 161 ms
55,732 KB
testcase_08 AC 156 ms
56,052 KB
testcase_09 AC 155 ms
55,740 KB
testcase_10 AC 157 ms
55,756 KB
testcase_11 AC 159 ms
54,508 KB
testcase_12 AC 162 ms
56,388 KB
testcase_13 AC 157 ms
56,028 KB
testcase_14 AC 142 ms
56,104 KB
testcase_15 AC 159 ms
56,268 KB
testcase_16 AC 146 ms
56,272 KB
testcase_17 WA -
testcase_18 AC 160 ms
55,736 KB
testcase_19 AC 155 ms
55,808 KB
testcase_20 WA -
testcase_21 AC 152 ms
55,796 KB
testcase_22 AC 139 ms
55,784 KB
testcase_23 AC 140 ms
54,108 KB
testcase_24 AC 160 ms
55,904 KB
testcase_25 AC 137 ms
56,332 KB
testcase_26 AC 138 ms
55,720 KB
testcase_27 AC 158 ms
55,936 KB
testcase_28 AC 157 ms
56,084 KB
testcase_29 AC 145 ms
55,780 KB
testcase_30 AC 173 ms
54,060 KB
testcase_31 AC 137 ms
55,812 KB
testcase_32 AC 140 ms
55,724 KB
testcase_33 AC 157 ms
55,960 KB
testcase_34 AC 137 ms
55,880 KB
testcase_35 AC 145 ms
53,788 KB
testcase_36 AC 157 ms
55,948 KB
testcase_37 AC 156 ms
53,572 KB
testcase_38 AC 157 ms
56,164 KB
testcase_39 AC 139 ms
55,824 KB
testcase_40 AC 159 ms
56,180 KB
testcase_41 AC 158 ms
56,108 KB
testcase_42 AC 151 ms
56,324 KB
testcase_43 AC 155 ms
55,896 KB
testcase_44 AC 151 ms
55,848 KB
testcase_45 AC 153 ms
56,176 KB
testcase_46 AC 142 ms
56,092 KB
testcase_47 WA -
testcase_48 AC 149 ms
55,996 KB
testcase_49 AC 142 ms
55,648 KB
testcase_50 AC 142 ms
55,768 KB
testcase_51 AC 148 ms
55,572 KB
testcase_52 AC 162 ms
55,792 KB
testcase_53 AC 157 ms
56,308 KB
testcase_54 AC 149 ms
55,936 KB
testcase_55 AC 146 ms
55,452 KB
testcase_56 AC 153 ms
55,792 KB
testcase_57 AC 138 ms
55,712 KB
testcase_58 AC 160 ms
56,024 KB
testcase_59 AC 161 ms
56,264 KB
testcase_60 AC 149 ms
55,992 KB
testcase_61 AC 157 ms
56,360 KB
testcase_62 AC 140 ms
55,772 KB
testcase_63 AC 141 ms
56,136 KB
testcase_64 AC 137 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No736 {
    public static void main(String[] args) {
    	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;
    			if(ama == 0) {
    				break;
    			}else {
    				si = bo;
        			bo = ama;
    			}
    		};
    		if(max == 1) {
    			max = bo;
    		}else if(max < bo) {
    			if(bo % max == 0) {
    				// nothing
    			}else {
    				max = 1;
    				break;
    			}
    		}else if(max > bo) {
    			if(max % bo == 0) {
    				max = bo;
    			}else {
    				max = 1;
    				break;
    			}
    		}
    		
    	}
//    	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("");
    	
    }
}
0