求助
  • 板块题目总版
  • 楼主heketian
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/10/13 13:33
  • 上次更新2023/10/27 07:41:59
查看原帖
求助
823474
heketian楼主2022/10/13 13:33

求助!!! P5723题想了好久没看出代码问题,哭死

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
   int L, n = 2, m = 0, num = 0, c;
   cin >> L;
   while (m <= L)
   {
   	if (n % 2 == 0 && n != 2)n++;
   	int i = 2;
   	c = sqrt(n);
   	while (i <= c && n % i != 0)i++;
   	if (i > c)
   	{
   		m = m + n;
   		if (m > L)break;
   		cout << n << endl;
   		num++;
   	}
   	n = n++;
   }
   cout << num << endl;
   return 0;
}
2022/10/13 13:33
加载中...