圆环上求素数III
This commit is contained in:
parent
6e418781f6
commit
f457f39977
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -24,7 +24,8 @@
|
|||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"unordered_map": "cpp",
|
"unordered_map": "cpp",
|
||||||
"unordered_set": "cpp",
|
"unordered_set": "cpp",
|
||||||
"string_view": "cpp"
|
"string_view": "cpp",
|
||||||
|
"cmath": "cpp"
|
||||||
},
|
},
|
||||||
"terminal.integrated.automationShell.windows": "cmd.exe",
|
"terminal.integrated.automationShell.windows": "cmd.exe",
|
||||||
"files.encoding": "gb18030",
|
"files.encoding": "gb18030",
|
||||||
|
3
1598_roundfind_sushu/Readme.md
Normal file
3
1598_roundfind_sushu/Readme.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# 标题
|
||||||
|
|
||||||
|
* 内容
|
1
1598_roundfind_sushu/doc/Readme.md
Normal file
1
1598_roundfind_sushu/doc/Readme.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
#
|
BIN
1598_roundfind_sushu/doc/圆环上求素数III.pdf
Normal file
BIN
1598_roundfind_sushu/doc/圆环上求素数III.pdf
Normal file
Binary file not shown.
81
1598_roundfind_sushu/main.cpp
Normal file
81
1598_roundfind_sushu/main.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int n, k,a[8] = { 0, 1, 2, 3, 4, 5, 6, 7 },allans=0;
|
||||||
|
bool ce[8]={0};
|
||||||
|
bool pan(int n)
|
||||||
|
{
|
||||||
|
int len = sqrt(n);
|
||||||
|
for (int i = 2; i <= len; i++) {
|
||||||
|
if (n % i == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void dg(int xian){
|
||||||
|
if(xian>n){
|
||||||
|
// for(int i=1;i<=n;i++){
|
||||||
|
// cout<<a[i]<<" ";
|
||||||
|
// }
|
||||||
|
// cout<<endl;
|
||||||
|
|
||||||
|
int now = 0, zong = 1, ans = 0;
|
||||||
|
for (int i = n - k + 2; i <= n; i++) {
|
||||||
|
now *= 10;
|
||||||
|
now += a[i];
|
||||||
|
zong *= 10;
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
now %= zong;
|
||||||
|
now *= 10;
|
||||||
|
now += a[i];
|
||||||
|
ans += pan(now);
|
||||||
|
}
|
||||||
|
if(ans>allans){
|
||||||
|
allans=ans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=2;i<=n;i++){
|
||||||
|
if(ce[i]==0){
|
||||||
|
a[xian]=i;
|
||||||
|
ce[i]=1;
|
||||||
|
dg(xian+1);
|
||||||
|
ce[i]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int now = 0, zong = 1, ans = 0;
|
||||||
|
cin >> n >> k;
|
||||||
|
if (k == 1) {
|
||||||
|
if (n == 1) {
|
||||||
|
cout << "0" << endl
|
||||||
|
<< "0";
|
||||||
|
} else {
|
||||||
|
int chu = 1;
|
||||||
|
for (int i = 3; i <= n; i+=2) {
|
||||||
|
chu++;
|
||||||
|
}
|
||||||
|
cout << chu << endl
|
||||||
|
<< chu;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = n - k + 2; i <= n; i++) {
|
||||||
|
now *= 10;
|
||||||
|
now += a[i];
|
||||||
|
zong *= 10;
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
now %= zong;
|
||||||
|
now *= 10;
|
||||||
|
now += a[i];
|
||||||
|
ans += pan(now);
|
||||||
|
}
|
||||||
|
cout<<ans<<endl;
|
||||||
|
dg(2);
|
||||||
|
cout<<allans;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
1598_roundfind_sushu/main.exe
Normal file
BIN
1598_roundfind_sushu/main.exe
Normal file
Binary file not shown.
1
1598_roundfind_sushu/test/in.txt
Normal file
1
1598_roundfind_sushu/test/in.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
7 1
|
1
1598_roundfind_sushu/test/in2.txt
Normal file
1
1598_roundfind_sushu/test/in2.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
7 3
|
1
1598_roundfind_sushu/test/in3.txt
Normal file
1
1598_roundfind_sushu/test/in3.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
6 4
|
21
1598_roundfind_sushu/test/out.txt
Normal file
21
1598_roundfind_sushu/test/out.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
## z:\Chao\src\1598_roundfind_sushu\test\in.txt
|
||||||
|
2020/06/13 ÖÜÁù 9:56:47.43
|
||||||
|
4
|
||||||
|
4
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 180 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\1598_roundfind_sushu\test\in2.txt
|
||||||
|
2020/06/13 ÖÜÁù 9:56:47.43
|
||||||
|
0
|
||||||
|
3
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 100 ms with return value 0
|
||||||
|
|
||||||
|
## z:\Chao\src\1598_roundfind_sushu\test\in3.txt
|
||||||
|
2020/06/13 ÖÜÁù 9:56:47.43
|
||||||
|
1
|
||||||
|
2
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 90 ms with return value 0
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user