結果

問題 No.358 も~っと!門松列
ユーザー tsunabittsunabit
提出日時 2019-06-02 11:36:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 1,074 bytes
コンパイル時間 3,727 ms
コンパイル使用メモリ 77,996 KB
実行使用メモリ 57,772 KB
最終ジャッジ日時 2023-10-17 22:58:06
合計ジャッジ時間 7,875 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,480 KB
testcase_01 AC 131 ms
57,464 KB
testcase_02 AC 135 ms
57,464 KB
testcase_03 AC 135 ms
57,312 KB
testcase_04 AC 134 ms
55,660 KB
testcase_05 AC 132 ms
57,640 KB
testcase_06 AC 133 ms
55,524 KB
testcase_07 AC 133 ms
57,488 KB
testcase_08 AC 137 ms
57,704 KB
testcase_09 AC 134 ms
57,236 KB
testcase_10 AC 134 ms
57,508 KB
testcase_11 AC 137 ms
57,524 KB
testcase_12 AC 135 ms
57,508 KB
testcase_13 AC 137 ms
57,480 KB
testcase_14 AC 134 ms
55,436 KB
testcase_15 AC 136 ms
57,532 KB
testcase_16 AC 132 ms
57,496 KB
testcase_17 AC 132 ms
57,496 KB
testcase_18 AC 130 ms
57,392 KB
testcase_19 AC 132 ms
57,772 KB
testcase_20 AC 132 ms
57,480 KB
testcase_21 AC 136 ms
57,520 KB
testcase_22 AC 136 ms
55,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No358 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner s = new Scanner(System.in);
        int a1 = s.nextInt(), a2 = s.nextInt(), a3 = s.nextInt();
        int max = Math.max(Math.max(a1, a2), a3);
        int min = Math.min(Math.min(a1, a2), a3);
        
        if(((max == a2) | (min == a2)) && (a1 != a2 && a1 != a3 && a2 != a3)) {
    		System.out.println("INF");
        }else {
        	int c = 0;
        	for(int i = 2; i <= max; i++) {
        		int temp_max = Math.max(Math.max(a1%i, a2%i), a3%i);
                int temp_min = Math.min(Math.min(a1%i, a2%i), a3%i);
                if((temp_max == a2%i && (a1%i != a2%i && a1%i != a3%i && a2%i != a3%i)) | (temp_min == a2%i && (a1%i != a2%i && a1%i != a3%i && a2%i != a3%i))) {
                	c++;
//                	System.out.println(a1%i + " , " + a2%i + " , " + a3%i);
                }
        	}
        	System.out.println(c);
        }
    }
}
0