0 Star 1 Fork 0

踏入メ荒唐路/java练习

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
HihoCoder1493.java 713 Bytes
Copy Edit Raw Blame History
踏入メ荒唐路 authored 2018-03-13 15:31 +08:00 . main
import java.util.Scanner;
public class HihoCoder1493 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
if (num >= 4 && num <= 1000000 && num%2==0) {
handle(num);
}
}
public static void handle(int num) {
int min=num;
for (int i = 3;i<= num;i+=2){
if(isPrime(num-i)&& isPrime(i)){
min=min<i?min:i;
}
}
System.out.println((min)+" "+(num-min));
}
/**
* жǷ
* @param n
* @return
*/
public static boolean isPrime(int n){
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
for (int i = 3;i*i<= n;i+=2){
if (n%i==0)
return false;
}
return true;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/lockJ/javaStudy.git
git@gitee.com:lockJ/javaStudy.git
lockJ
javaStudy
java练习
master

Search