评测RE,IDE上AC

P1865 A % B Problem

数组越界了吧
by Siyuan @ 2018-07-21 15:35:57


std?
by henrytb @ 2018-07-21 15:39:15


异常抓取成功。 **Code** ```cpp #include<bits/stdc++.h> int i,n,t,p,q,j,m; std::vector<int> a(1000000); int main(){ try { std::scanf("%d%d",&n,&m); for(i=2;i<=(int)sqrt(m);++i) if(a.at(i)==0) for(j=i*i;j<=m;j+=i)a.at(j)=1;a[1]=1; for(i=1;i<=n;++i){ std::scanf("%d%d",&p,&q); if(q>m||q<1||p<1)printf("Crossing the line\n"); else{ for(j=p;j<=q;++j) if(a.at(j)==0)++t; std::printf("%d\n",t);t=0; } } return 0; } catch(std::exception& e) { std::cerr<<"\n\n"<<e.what(); } } ``` 在数据点4 5 6 7 14成功抓取越界异常(当然我提交的时候是用了catch(...)因为懒……) 我可是用了我的下载次数两次呢! 输出如下 ``` 100 1000000 vector::_M_range_check Out Of Range ``` 另外一个小点。 `#pragma optimize`只有在编译C有用 详见http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48026
by constructor @ 2018-07-21 15:59:01


哦 现在才看到您发了评测记录。。。早知道就让您把数据发给我了,【手动滑稽】
by constructor @ 2018-07-21 16:02:21


另外,越界在这里: >if(a.at(j)==0)++t;
by constructor @ 2018-07-21 16:08:40


@[constructor](/space/show?uid=56461) 也就是说去掉O3?
by FCBM71 @ 2018-07-21 16:32:57


@[FCBM71](/space/show?uid=45176) 没用。
by constructor @ 2018-07-21 16:33:37


@[FCBM71](/space/show?uid=45176) 你越界了,不是O3的问题,甚至你那O3被编译器无视了
by constructor @ 2018-07-21 16:34:02


@[constructor](/space/show?uid=56461) 现在越界解决了,但是TLE了
by FCBM71 @ 2018-07-21 16:43:02


@[constructor](/space/show?uid=56461) @[siyuan](/space/show?uid=49725) 已AC,谢谢
by FCBM71 @ 2018-07-21 16:46:38


|