样例2,10超时
查看原帖
样例2,10超时
534532
AnthonyEric楼主2022/1/18 23:15
#include<bits/stdc++.h>
using namespace std;

bool judge(int x){
    for(int i = 2; i * i <= x; i++){
    	if(x % i == 0){
			return false;
		} 
	}
	return true;
}
void meiju(int y){
	for(int i = 2; i <= y; i++){
		for(int j = 2; j <= y; j++){
			if(judge(i) == true && judge(j) == true  && i + j == y)
			{
				cout << y << '=' << i << '+' << j ;
				return;
			}
		}
	}

}
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 4; i<= n;i+=2){
		meiju(i);
		if(i != n) cout << '\n';
	}
	return 0;
}

技术很差,求谅解,谢谢。

2022/1/18 23:15
加载中...