結果

問題 No.358 も~っと!門松列
ユーザー 37zigen37zigen
提出日時 2016-04-17 22:43:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 721 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 75,452 KB
実行使用メモリ 54,444 KB
最終ジャッジ日時 2024-04-15 02:21:19
合計ジャッジ時間 5,435 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
53,120 KB
testcase_01 AC 108 ms
53,152 KB
testcase_02 AC 120 ms
54,212 KB
testcase_03 AC 119 ms
53,980 KB
testcase_04 AC 105 ms
53,072 KB
testcase_05 AC 119 ms
54,444 KB
testcase_06 AC 120 ms
54,020 KB
testcase_07 AC 106 ms
52,740 KB
testcase_08 AC 111 ms
53,420 KB
testcase_09 AC 122 ms
54,100 KB
testcase_10 AC 129 ms
54,068 KB
testcase_11 AC 116 ms
54,128 KB
testcase_12 AC 114 ms
54,132 KB
testcase_13 AC 116 ms
54,264 KB
testcase_14 AC 106 ms
53,028 KB
testcase_15 AC 102 ms
52,800 KB
testcase_16 AC 137 ms
54,080 KB
testcase_17 AC 124 ms
53,884 KB
testcase_18 AC 116 ms
54,184 KB
testcase_19 AC 114 ms
53,976 KB
testcase_20 AC 116 ms
54,216 KB
testcase_21 AC 113 ms
54,200 KB
testcase_22 AC 118 ms
54,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int a1=sc.nextInt();
		int a2=sc.nextInt();
		int a3=sc.nextInt();
		int max=Math.max(a1, a2);
		max=Math.max(max, a3);
		int count=0;
		for(int i=1001;i>=1;i--){
			if(judge(a1,a2,a3,i)){
				if(i==1001){
					System.out.println("INF");
					return;
				}
				count++;
			}
		}
		System.out.println(count);
			
	}
	//カラマツか判断
	boolean judge(int a1,int a2,int a3,int p){
		a1%=p;
		a2%=p;
		a3%=p;
		if(!(a1!=a2&&a2!=a3&&a3!=a1))return false;
		if(a1>a2&&a2>a3)return false;
		if(a1<a2&&a2<a3)return false;
		return true;
	}
}
0