結果

問題 No.358 も~っと!門松列
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-27 23:18:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 957 bytes
コンパイル時間 3,609 ms
コンパイル使用メモリ 77,852 KB
実行使用メモリ 41,688 KB
最終ジャッジ日時 2024-04-16 18:00:31
合計ジャッジ時間 7,179 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,688 KB
testcase_01 AC 129 ms
41,552 KB
testcase_02 AC 130 ms
41,460 KB
testcase_03 AC 129 ms
41,472 KB
testcase_04 AC 128 ms
41,528 KB
testcase_05 AC 128 ms
41,404 KB
testcase_06 AC 129 ms
41,444 KB
testcase_07 AC 129 ms
41,556 KB
testcase_08 AC 127 ms
41,280 KB
testcase_09 AC 131 ms
41,380 KB
testcase_10 AC 130 ms
41,648 KB
testcase_11 AC 133 ms
41,640 KB
testcase_12 AC 129 ms
41,600 KB
testcase_13 AC 126 ms
41,432 KB
testcase_14 AC 129 ms
41,636 KB
testcase_15 AC 133 ms
41,468 KB
testcase_16 AC 129 ms
41,492 KB
testcase_17 AC 131 ms
41,288 KB
testcase_18 AC 115 ms
41,280 KB
testcase_19 AC 131 ms
41,408 KB
testcase_20 AC 132 ms
41,340 KB
testcase_21 AC 129 ms
41,220 KB
testcase_22 AC 134 ms
41,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercises25{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int[] array = new int[3];

    for (int n = 0; n < 3; n++){
      array[n] = sc.nextInt();
    }

    int count = 0;

    if (array[0] == array[1] || array[0] == array[2] || array[1] == array[2]){
      System.out.println(0);
    }else if (array[1] > array[0] && array[1] > array[2] || array[1] < array[0] && array[1] < array[2]){
      System.out.println("INF");
    }else{
      int bigger = Math.max(array[0], array[1]);
      int max = Math.max(bigger, array[2]);
      for (int p = 2; p <= max; p++){
        int first = array[0] % p;
        int second = array[1] % p;
        int third = array[2] % p;

        if (first != third){
          if (second > first && second > third || second < first && second < third){
            count++;
          }
        }
      }
      System.out.println(count);
    }

  }
}
0