1 条题解

  • 1
    @ 2025-4-18 22:13:32
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,s=0,t=2,i,k=0;
    	cin>>n;
    	while(s<=n)
    	{
    		for(i=2; i<=sqrt(t); i++)
    		{
    			if(t%i==0)
    			{
    				break;
    			}
    		}
    		if(i>sqrt(t))
    		{
    			if(s+t<=n)
    			{
    				cout<<t<<endl;
    				k++;
    			}
    			s+=t;
    		}
    		t++;
    	}
    	cout<<k;
    	return 0;
    }
    
    

    信息

    编号
    2334
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    49
    已通过
    21
    上传者