結果

問題 No.312 置換処理
ユーザー mits58mits58
提出日時 2016-07-29 22:32:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 54,492 KB
最終ジャッジ日時 2024-04-27 10:46:26
合計ジャッジ時間 7,688 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
54,428 KB
testcase_01 AC 113 ms
53,296 KB
testcase_02 AC 112 ms
52,852 KB
testcase_03 AC 112 ms
54,352 KB
testcase_04 AC 109 ms
53,716 KB
testcase_05 AC 101 ms
52,728 KB
testcase_06 AC 103 ms
53,300 KB
testcase_07 AC 119 ms
53,828 KB
testcase_08 AC 112 ms
54,284 KB
testcase_09 AC 108 ms
53,740 KB
testcase_10 AC 108 ms
54,192 KB
testcase_11 AC 115 ms
54,268 KB
testcase_12 AC 108 ms
53,808 KB
testcase_13 AC 112 ms
54,396 KB
testcase_14 AC 97 ms
53,048 KB
testcase_15 AC 101 ms
53,352 KB
testcase_16 AC 109 ms
53,936 KB
testcase_17 AC 100 ms
52,912 KB
testcase_18 AC 114 ms
53,964 KB
testcase_19 AC 109 ms
54,392 KB
testcase_20 AC 110 ms
53,836 KB
testcase_21 AC 101 ms
52,616 KB
testcase_22 AC 110 ms
54,120 KB
testcase_23 AC 114 ms
53,876 KB
testcase_24 AC 107 ms
52,716 KB
testcase_25 AC 104 ms
53,280 KB
testcase_26 AC 112 ms
54,352 KB
testcase_27 AC 108 ms
53,972 KB
testcase_28 AC 110 ms
54,268 KB
testcase_29 AC 127 ms
54,076 KB
testcase_30 AC 114 ms
54,036 KB
testcase_31 AC 115 ms
54,100 KB
testcase_32 AC 112 ms
53,628 KB
testcase_33 AC 118 ms
53,756 KB
testcase_34 AC 116 ms
54,104 KB
testcase_35 AC 109 ms
53,972 KB
testcase_36 AC 107 ms
54,120 KB
testcase_37 AC 111 ms
53,888 KB
testcase_38 AC 107 ms
53,964 KB
testcase_39 AC 97 ms
53,136 KB
testcase_40 AC 108 ms
53,784 KB
testcase_41 AC 108 ms
54,492 KB
testcase_42 AC 108 ms
54,192 KB
testcase_43 AC 109 ms
53,808 KB
testcase_44 AC 99 ms
53,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	static boolean isprime(long x){
		if(x==1) return false;
		for(long i=2;i*i<=x;i++) if(x%i==0) return false;
		return true;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long n=sc.nextLong();
			if(isprime(n) || n==4) System.out.println(n);
			else{
				boolean flag=true;
				for(long i=3;i*i<=n;i++){
					if(n%i==0){
						System.out.println(i);
						flag=false;
						break;
					}
				}
				if(flag) System.out.println(n/2);
			}
		}
	}
}
0