93分,蜜汁RE

P1865 A % B Problem

没看出问题…… 你参考一下我的代码吧。素数筛专门造了个函数,可能清楚点 ```cpp #include<bits/stdc++.h> using namespace std; int a[10000001]; int cnt[10000001]; void shai(int max) { for(int i=2;i<=max;i++) { cnt[i]=cnt[i-1]; if(!a[i]) {for(int k=i;k<=max/i;k++) a[i*k]=1;cnt[i]++;} } } int main() { int n,m; cin>>n>>m; shai(m); //for(int i=1;i<=m;i++) cout<<cnt[i]<<' '; //cout<<endl; for(int i=1;i<=n;i++) { int l,r; cin>>l>>r; if(r>m || r<1 || l<1) cout<<"Crossing the line"<<endl; else cout<<cnt[r]-cnt[l-1]<<endl; } } ```
by x义x @ 2018-05-02 20:59:28


@[Ruff](/space/show?uid=30205) 把你的 bool vis[1000100]; bool primes[1000100]; 改为 bool vis[10000001]; bool primes[10000001]; 就过了。 本人已测过
by Sam_Shen_141530 @ 2018-08-15 14:11:10


@[Sam_Shen_141530](/space/show?uid=13723) 为什么呀,我改了之后也从re变成ac了
by sunzhen @ 2019-02-15 14:31:35


因为你范围小了@[sunzhen](/space/show?uid=179811)
by Sam_Shen_141530 @ 2019-02-17 19:58:02


|