結果

問題 No.358 も~っと!門松列
ユーザー fjafjafjafjafjafja
提出日時 2017-09-17 23:12:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 794 bytes
コンパイル時間 3,146 ms
コンパイル使用メモリ 77,448 KB
実行使用メモリ 54,536 KB
最終ジャッジ日時 2024-04-25 15:02:24
合計ジャッジ時間 6,916 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
54,068 KB
testcase_01 AC 123 ms
54,232 KB
testcase_02 AC 123 ms
53,896 KB
testcase_03 AC 110 ms
53,028 KB
testcase_04 AC 122 ms
54,140 KB
testcase_05 AC 126 ms
54,312 KB
testcase_06 AC 119 ms
54,048 KB
testcase_07 AC 126 ms
54,096 KB
testcase_08 AC 124 ms
54,184 KB
testcase_09 AC 120 ms
54,120 KB
testcase_10 AC 121 ms
54,028 KB
testcase_11 AC 123 ms
54,536 KB
testcase_12 AC 124 ms
54,444 KB
testcase_13 AC 119 ms
53,856 KB
testcase_14 AC 122 ms
54,308 KB
testcase_15 AC 122 ms
54,380 KB
testcase_16 AC 120 ms
54,148 KB
testcase_17 AC 122 ms
54,124 KB
testcase_18 AC 123 ms
54,100 KB
testcase_19 AC 112 ms
52,980 KB
testcase_20 AC 118 ms
54,044 KB
testcase_21 AC 123 ms
54,104 KB
testcase_22 AC 113 ms
53,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N358 {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int[] a=new int[3];
		int[] buf=new int[3];
		int max=0;
		int cnt=0;
		for(int i=0;i<3;i++)
		{
			a[i]=sc.nextInt();
			max=(max<a[i])?a[i]:max;
		}
		if(issame(a)){System.out.println("0");}
		else if(iskado(a))
		{System.out.println("INF");}
		else
		{
			for(int p=1;p<=max;p++)
			{
				for(int i=0;i<3;i++)
				{
					buf[i]=a[i]%p;
				}
				if((!issame(buf))&&iskado(buf))
				{
					cnt++;
				}
			}
			System.out.println(cnt);
		}

	}
	static boolean issame(int[] a)
	{
		return a[0]==a[1]||a[1]==a[2]||a[2]==a[0];
	}
	static boolean iskado(int[] a)
	{
		if((a[1]>a[0]&&a[1]>a[2])||(a[1]<a[0]&&a[1]<a[2]))
		{
			return true;
		}
		return false;
	}

}
0