{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "7b4639bc58ec40cba62d0e7025d4600d",
  "keywords": "算法高阶,数论算法,素数的测试,算法问题选编",
  "title": "求前n个素数之和",
  "desc": [
    {
      "content": "\n题目描述\n求前n个素数的和。 \n例如，前5个素数是2、3、5、7、11，它们的和是28。 \n输入\n一个整数n，1<=n<=1000。 \n输出\n前n个素数的和 \n样例输入\n5\n样例输出\n28\n提示\n第1000个素数是7919。",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <iostream>\nusing namespace std;\nint main()\n{\n\tint n,i,j,sum,a;\n\tcin>>n;\n\ta = 0;\n\ti = 2;\n\tsum=0;\n\twhile(a<n){\n\t\tfor(j=2;j<=i;j++)\n\t\t\tif(i%j == 0)\n\t\t\t\tbreak;\n\t\tif(j == i)\n\t\t{\n\t\t\tsum += i;\n\t\t\t++a;\n\t\t}\n\t\t++i;\n\t}\n\tcout<<sum;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-8159c79d4b6e4544bf44d1f7b9a57ff9",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600469943"
}