結果

問題 No.358 も~っと!門松列
ユーザー 37zigen
提出日時 2016-04-17 22:43:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 721 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 54,244 KB
最終ジャッジ日時 2024-10-04 10:39:58
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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