社区讨论
求教TT,第一次尝试使用关闭同步,但总是编译错误,是哪里写错了吗
P3383【模板】线性筛素数参与者 6已保存回复 20
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 20 条
- 当前快照
- 1 份
- 快照标识符
- @mhjhaq4z
- 此快照首次捕获于
- 2025/11/04 02:33 4 个月前
- 此快照最后确认于
- 2025/11/04 06:18 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
long n,k,cnt,P[10000001];
bool np[100000001];//**难道是空间开太大了吗**
int q;
void Euler(int n)
{
cnt=0;
np[0]=np[1]=true;
for(int i=2;i<=n;i++)
{
if(!np[i])P[++cnt]=i;//存质数
for(int j=1;j<=cnt&&P[j]*i<=n;j++)
{
np[P[j]*i]=true;//标记合数
if(i%P[j]==0)break;//不是最小质因数
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);//难道是格式有错误?
cin>>n>>q;
Euler(n);
for(int i=0;i<q;i++)
{
cin>>k;
cout<<P[k]<<'\n';
}
return 0;
}
|这是编译错误的信息,我每次都看不懂
/tmp/compiler_1loaxj7h/src:23:1: 错误:程序中有游离的‘\357’
23 | {
| ^
/tmp/compiler_1loaxj7h/src:23:2: 错误:程序中有游离的‘\275’
23 | {
| ^
/tmp/compiler_1loaxj7h/src:23:3: 错误:程序中有游离的‘\233’
23 | {
| ^
/tmp/compiler_1loaxj7h/src:35:1: 错误:程序中有游离的‘\357’
35 | }
| ^
/tmp/compiler_1loaxj7h/src:35:2: 错误:程序中有游离的‘\275’
35 | }
| ^
/tmp/compiler_1loaxj7h/src:35:3: 错误:程序中有游离的‘\235’
35 | }
| ^
/tmp/compiler_1loaxj7h/src:24:2: 错误:expected initializer before ‘std’
24 | std::ios::sync_with_stdio(0);
| ^~~
/tmp/compiler_1loaxj7h/src:25:2: 错误:‘cin’ does not name a type; did you mean ‘sin’?
25 | cin.tie(0);
| ^~~
| sin
/tmp/compiler_1loaxj7h/src:26:2: 错误:‘cout’不是一个类型名
26 | cout.tie(0);
| ^~~~
/tmp/compiler_1loaxj7h/src:27:5: 错误:‘cin’ does not name a type; did you mean ‘sin’?
27 | cin>>n>>q;
| ^~~
| sin
/tmp/compiler_1loaxj7h/src:28:7: 错误:expected constructor, destructor, or type conversion before ‘(’ token
28 | Euler(n);
| ^
/tmp/compiler_1loaxj7h/src:29:2: 错误:expected unqualified-id before ‘for’
29 | for(int i=0;i<q;i++)
| ^~~
/tmp/compiler_1loaxj7h/src:29:14: 错误:‘i’不是一个类型名
29 | for(int i=0;i<q;i++)
| ^
/tmp/compiler_1loaxj7h/src:29:18: 错误:‘i’不是一个类型名
29 | for(int i=0;i<q;i++)
| ^
/tmp/compiler_1loaxj7h/src:34:2: 错误:expected unqualified-id before ‘return’
34 | return 0;
| ^~~~~~
|
|:--------:|
回复
共 20 条回复,欢迎继续交流。
正在加载回复...