結果

問題 No.1113 二つの整数 / Two Integers
ユーザー tentententen
提出日時 2023-08-01 17:54:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 2,116 bytes
コンパイル時間 2,752 ms
コンパイル使用メモリ 82,652 KB
実行使用メモリ 37,052 KB
最終ジャッジ日時 2024-04-19 17:06:43
合計ジャッジ時間 4,129 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
36,584 KB
testcase_01 AC 48 ms
36,708 KB
testcase_02 AC 48 ms
36,972 KB
testcase_03 AC 49 ms
36,820 KB
testcase_04 AC 48 ms
36,596 KB
testcase_05 AC 48 ms
36,464 KB
testcase_06 AC 49 ms
37,016 KB
testcase_07 AC 48 ms
36,704 KB
testcase_08 AC 49 ms
36,868 KB
testcase_09 AC 48 ms
36,748 KB
testcase_10 AC 50 ms
36,984 KB
testcase_11 AC 46 ms
36,576 KB
testcase_12 AC 50 ms
36,836 KB
testcase_13 AC 49 ms
37,032 KB
testcase_14 AC 50 ms
37,052 KB
testcase_15 AC 48 ms
36,592 KB
testcase_16 AC 50 ms
37,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long gcd = getGCD(sc.nextLong(), sc.nextLong());
        if (isSquare(gcd)) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
    
    static boolean isSquare(long x) {
        long left = 1;
        long right = Integer.MAX_VALUE;
        while (right - left > 1) {
            long m = (left + right) / 2;
            if (m * m <= x) {
                left = m;
            } else {
                right = m;
            }
        }
        return left * left == x;
    }
    
    static long getGCD(long x, long y) {
        if (y == 0) {
            return x;
        } else {
            return getGCD(y, x % y);
        }
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0