結果

問題 No.358 も~っと!門松列
ユーザー mits58mits58
提出日時 2016-07-02 20:51:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 603 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 79,792 KB
実行使用メモリ 54,432 KB
最終ジャッジ日時 2024-04-20 06:09:58
合計ジャッジ時間 5,734 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
53,992 KB
testcase_01 AC 114 ms
53,440 KB
testcase_02 AC 116 ms
54,028 KB
testcase_03 AC 126 ms
54,088 KB
testcase_04 AC 126 ms
54,104 KB
testcase_05 AC 130 ms
54,252 KB
testcase_06 AC 125 ms
54,060 KB
testcase_07 AC 123 ms
53,864 KB
testcase_08 AC 124 ms
53,976 KB
testcase_09 AC 126 ms
53,952 KB
testcase_10 AC 122 ms
54,120 KB
testcase_11 AC 124 ms
53,948 KB
testcase_12 AC 127 ms
54,048 KB
testcase_13 AC 123 ms
54,132 KB
testcase_14 AC 128 ms
54,152 KB
testcase_15 AC 125 ms
54,108 KB
testcase_16 AC 112 ms
52,696 KB
testcase_17 AC 123 ms
54,108 KB
testcase_18 AC 113 ms
54,008 KB
testcase_19 AC 117 ms
54,432 KB
testcase_20 AC 118 ms
53,980 KB
testcase_21 AC 116 ms
54,232 KB
testcase_22 AC 118 ms
54,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a1=sc.nextInt();
			int a2=sc.nextInt();
			int a3=sc.nextInt();
			if(a1==a2 || a1==a3 || a2==a3) System.out.println(0);
			else if(a2>a1 && a2>a3 || a2<a1 && a2<a3) System.out.println("INF");
			else{
				int ans=0;
				for(int i=2;i<=Math.max(a1,Math.max(a2,a3));i++){
					int b1=a1%i,b2=a2%i,b3=a3%i;
					if(b1==b2 || b3==b1 || b2==b3) continue;
					if(b2>b1 && b2>b3 || b2<b1 && b2<b3) ans++;
				}
				System.out.println(ans);
			}
		}
	}
}
0