@[Haidde](https://www.luogu.com.cn/user/1215070)
C++[AC](https://www.luogu.com.cn/record/136652067)代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
int main() {
int L,i,j,sum=0,x,n=0;
cin>>L;
if(L==1){
cout<<0;
return 0;
}
for(i=2; ;i++){
x=1;
for(j=2;j<=i;j++){
if(i%j==0){
x++;
}
}
if(x==2){
sum=sum+i;
if(sum >L){
break;
}
n++;
cout<<i<<endl;
}
}
cout<<n;
return 0;
}
```
by huangkaikai @ 2024-02-19 10:20:38
@[Haidde](/user/1215070) 审题没有对哦,题目中说装质数的袋子不能超过给定的数L。而你的代码最后一个质数加上去会超过L,所以同时你的计数器X也会多算一个。
by LSQS @ 2024-02-25 18:58:51