社区讨论
后面五个点全TLE
P3912素数个数参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lxd841uz
- 此快照首次捕获于
- 2024/06/13 20:15 2 年前
- 此快照最后确认于
- 2024/06/13 23:12 2 年前
CPP
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z,o) for(int o=x;o<=y;o+=z)
const int N=1e8+5;
using namespace std;
bool f[N];
void read(LL &sum)
{
sum=0;int p=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') p=-1;
for(; isdigit(ch);ch=getchar()) sum=sum*10+ch-48;
sum*=p;
}
void write(LL x)
{
if(x>9)
{
write(x/10);
x%=10;
}
putchar(x+'0');
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
LL ans=0;
LL n;
read(n);
f[1]=1;
F(2,n/i,1,i)
{
if(f[i]==0)
{
F(i*i,n,i,j)
{
f[j]=1;
}
}
}
F(1,n,1,i)
{
if(!f[i]) ans++;
}
write(ans);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...