結果
| 問題 |
No.358 も~っと!門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-29 12:11:57 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 131 ms / 1,000 ms |
| コード長 | 1,095 bytes |
| コンパイル時間 | 1,969 ms |
| コンパイル使用メモリ | 77,048 KB |
| 実行使用メモリ | 41,808 KB |
| 最終ジャッジ日時 | 2024-10-12 08:13:15 |
| 合計ジャッジ時間 | 5,755 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int A[] = new int[3], B[] = new int[3], ans = 0, minA = Integer.MAX_VALUE, maxA = Integer.MIN_VALUE, minB, maxB;
for (int i = 0; i < 3; ++i) {
A[i] = sc.nextInt();
minA = Math.min(minA, A[i]);
maxA = Math.max(maxA, A[i]);
}
sc.close();
if (A[0] != A[1] && A[1] != A[2] && A[0] != A[2] && (A[1] == minA || A[1] == maxA)) System.out.print("INF");
else {
for (int i = 1; i <= maxA; ++i) {
minB = Integer.MAX_VALUE;
maxB = Integer.MIN_VALUE;
for (int j = 0; j < 3; ++j) {
B[j] = A[j] % i;
minB = Math.min(minB, B[j]);
maxB = Math.max(maxB, B[j]);
}
if (B[0] != B[1] && B[1] != B[2] && B[0] != B[2] && (B[1] == minB || B[1] == maxB)) ++ans;
}
System.out.print(ans);
}
}
}