Gravatar
锝镆氪锂铽
积分:939
提交:367 / 832
我不明白,为什么这么个题不会忽略换行,为什么输入不给个 m 确定数据数,为什么明明 1 没法弄环测试数据还有 1 ?

题目 2668 素数环
2020-08-24 17:21:29
Gravatar
魔笛
积分:457
提交:208 / 505
补充楼上的,case之后还有冒号...粗心害死人

题目 2668 素数环
2020-08-19 20:16:36
Gravatar
wire
积分:359
提交:153 / 345
格式很坑,卡了两点:
1.case的大小写
2.空格和换行的问题

题目 2668 素数环
2019-07-06 12:02:51
Gravatar
cosmosMeta
积分:118
提交:38 / 180
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
bool judge(int q);
bool b[1000]={0};
int m,a[1000],j=0;
void print(int n);
int sea(int x,int n)
{
for(int i=2;i<=n;i++)
if(b[i]==0&&judge(i+a[x-1]))
{
a[x]=i;
b[i]=1;
if(x==n){
if(judge(a[x]+a[1]))
print(m);
}
else
sea(x+1,n);
b[i]=0;
}
}
bool judge(int q)
{
if(q==1)
return 0;
for(int i=2;i<=sqrt(q);i++)
{
if(q%i==0)
return 0;
}
return 1;
}
void print(int n)
{
for(int i=1;i<=n;i++)
{
if(i!=1)
cout<<' ';
cout<<a[i];
}
cout<<endl;
}
int main()
{
freopen("primering.in","r",stdin);
freopen("primering.out","w",stdout);
while(scanf("%d",&m)==1)
{
++j;
cout<<"Case "<<j<<':'<<endl;
a[1]=1;
b[1]=1;
sea(2,m);
//system("pause");
cout<<endl;
}
}// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

题目 2668 素数环
2017-04-20 10:31:56