結果

問題 No.809 かけ算
ユーザー GetDazeGetDaze
提出日時 2019-08-09 16:38:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 2,814 ms
コンパイル使用メモリ 73,676 KB
実行使用メモリ 56,916 KB
最終ジャッジ日時 2023-09-26 13:16:42
合計ジャッジ時間 4,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
56,576 KB
testcase_01 AC 145 ms
56,480 KB
testcase_02 AC 144 ms
54,840 KB
testcase_03 AC 142 ms
56,628 KB
testcase_04 AC 144 ms
56,916 KB
testcase_05 AC 144 ms
54,644 KB
testcase_06 AC 145 ms
56,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);

        // int 1つ分を読み込む
        int C = sc.nextInt();
        int A = 1;
        int B = C;
        
        if(C%2==0)
        {
            A = 2;
            B = C/2;
            System.out.println(A + " " + B);
        }
        else
        {
            int SQ = (int)(Math.ceil(Math.sqrt((double)C)));
            for(int i = 3; i < SQ; i+=2)
            {
                if(C%i == 0)
                {
                    A = i;
                    B = C/i;
                    System.out.println(A + " " + B);
                    break;
                }
            }
            if(A == 1)
            {
                System.out.println(A + " " + B);
            }
        }
    }
}
0