diff --git a/1656_brotherthink/Readme.md b/1656_brotherthink/Readme.md new file mode 100644 index 0000000..d34a2d9 --- /dev/null +++ b/1656_brotherthink/Readme.md @@ -0,0 +1,23 @@ +# 哥德巴赫猜想的所有解 + +[问题描述] + +教学案例,必须使用函数完成求解! + +  求出哥德巴赫猜想的所有解(将一个大于9的奇数拆分成三个素数之和),并按从小到的顺序写出。 + +[输入格式] +  一行,一个大于9的奇数。 + +[输出格式] +  第1行,一个整数N,表示解的总数。 +  第2至N+1行,每行一个解。 + +[输入样例] +15 + +[输出样例] +3 +15=2+2+11 +15=3+5+7 +15=5+5+5 diff --git a/1656_brotherthink/brotherthink.cpp b/1656_brotherthink/brotherthink.cpp new file mode 100644 index 0000000..ee5fc07 --- /dev/null +++ b/1656_brotherthink/brotherthink.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +int zh[10000001]={1},a[10000001][4]; +bool zhi(int n){ + for(int i=2;i*i<=n;i++){ + if(n%i==0){ + return 0; + } + } + return 1; +} +int main(){ + int n,ans=0; + cin>>n; + zh[1]=2; + for(int i=3;i<=n-4;i++){ + if(zhi(i)==1){ + zh[++zh[0]]=i; + } + } + for(int i=1;zh[i]*3<=n;i++){ + for(int j=i;zh[j]<=n-zh[i]-zh[j];j++){ + int now=n-zh[i]-zh[j]; + if(zhi(now)==1){ + ans++; + a[ans][1]=zh[i]; + a[ans][2]=zh[j]; + a[ans][3]=now; + } + } + } + cout< + +int main() +{ + std::cout << "Hello Easy C++ project!" << std::endl; +} diff --git a/1656_brotherthink/main.exe b/1656_brotherthink/main.exe new file mode 100644 index 0000000..fc4df42 Binary files /dev/null and b/1656_brotherthink/main.exe differ diff --git a/1656_brotherthink/test/in.txt b/1656_brotherthink/test/in.txt new file mode 100644 index 0000000..3f10ffe --- /dev/null +++ b/1656_brotherthink/test/in.txt @@ -0,0 +1 @@ +15 \ No newline at end of file diff --git a/1656_brotherthink/test/in2.txt b/1656_brotherthink/test/in2.txt new file mode 100644 index 0000000..d97edbb --- /dev/null +++ b/1656_brotherthink/test/in2.txt @@ -0,0 +1 @@ +99 \ No newline at end of file diff --git a/1656_brotherthink/test/out.txt b/1656_brotherthink/test/out.txt new file mode 100644 index 0000000..6565f22 --- /dev/null +++ b/1656_brotherthink/test/out.txt @@ -0,0 +1,45 @@ +## z:\Chao\src\1656_brotherthink\test\in.txt +2020/04/05 周日 22:37:20.09 +3 +15=2+2+11 +15=3+5+7 +15=5+5+5 +----------------------------------------------- +Process exited after 210 ms with return value 0 + +## z:\Chao\src\1656_brotherthink\test\in2.txt +2020/04/05 周日 22:37:20.09 +30 +99=3+7+89 +99=3+13+83 +99=3+17+79 +99=3+23+73 +99=3+29+67 +99=3+37+59 +99=3+43+53 +99=5+5+89 +99=5+11+83 +99=5+23+71 +99=5+41+53 +99=5+47+47 +99=7+13+79 +99=7+19+73 +99=7+31+61 +99=11+17+71 +99=11+29+59 +99=11+41+47 +99=13+13+73 +99=13+19+67 +99=13+43+43 +99=17+23+59 +99=17+29+53 +99=17+41+41 +99=19+19+61 +99=19+37+43 +99=23+23+53 +99=23+29+47 +99=29+29+41 +99=31+31+37 +----------------------------------------------- +Process exited after 90 ms with return value 0 +