#2过 其他都WA,自测无误,求助
查看原帖
#2过 其他都WA,自测无误,求助
714500
Tennif_hxz楼主2023/7/6 13:15
#include <bits/stdc++.h>
using namespace std;

int su[100003],shu[100003];

int main(){

	ios::sync_with_stdio (0);
	cin.tie (0);cout.tie (0);

	int n,i,s,top,num,sum,l=1;
	cin>>n;
	su[1]=2;
	shu[2]=1;
	top=0;
	i=1;
	while(n>sum)
	{
		i++;
		s=1;
		num=sqrt(i);
		/*while(shu[num]==0) num--;
		l=shu[num];
		for(int r=l;r>=1;r--)
		{
			if(i%su[r]==0) 
			{
				s++;
				break;
			}
		}*/
		for(int r=2;r<=num;r++)
		{
			if(i%r==0) 
			{
				s++;
				break;
			}
		}
		if(s==1)
		{
			//su[top]=i;
			//shu[i]=top;
			sum+=i;
			if(n<sum) break;
			cout<<i<<endl;
			top++;
		}
	}
	cout<<top;
	return 0;
}
2023/7/6 13:15
加载中...