社区讨论
90分求助,一个TLE实在过不了
P1304哥德巴赫猜想参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lvntvpy4
- 此快照首次捕获于
- 2024/05/01 21:03 2 年前
- 此快照最后确认于
- 2024/05/02 09:28 2 年前
90分求助,一个TLE实在过不了
CPP#include<iostream>
#include<fstream>
#include <iomanip>
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
int n,s=0,f=0,flag=1;
cin>>n;
for(int o=4;o<=n;o+=2){
flag=1;
for(int j=2;j<o;j++){
int m=1;
for(int i=2;i<=sqrt(j);i++){
if(j%i==0){
m=0;break;
}
}
if(!m) continue;
for(int t=j;t<=o-j;t++){
int k=1;
for(int g=2;g<=sqrt(t);g++){
if(t%g==0){
k=0;break;
}
}
if(!k) continue;
if((j+t)==o){
cout<<o<<"="<<j<<"+"<<t<<endl;
flag=0;break;
}
}
if(flag==0) break;
}
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...