19.json 2.0 KB
Newer Older
每日一练社区's avatar
test  
每日一练社区 已提交
1
{
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  "question_id": 7457152,
  "question_title": "1,3,3,5,5,5,7,7,7,7,9,9,9,9,9,.....",
  "question_content": "<p><a href=\"http://114.67.86.56:5000/Problem_Show.asp?id&#61;1045\">简单数列5</a><br />\n<strong> </strong>已知一数列&#xff1a;1,3,3,5,5,5,7,7,7,7,9,9,9,9,9,11,11,11,11,11,11,11.....请根据规律求出第n项的值。例如&#xff1a;n&#61;4 项时&#xff0c;其值为5,n&#61;11时&#xff0c;其值为9.\n<strong>输入格式 </strong>一个自然数n,(0&lt;n&lt;1000)<br />\n<br />\n<strong>输出格式</strong> 一个整数&#xff0c;即第n项的值。<br />\n<strong>样例输入&#xff1a;4</strong><br />\n<strong>样例输出 &#xff1a;5</strong></p>\n",
  "difficulty": "简单",
  "answer_id": 53441264,
  "answer_content": "<pre>\n<code class=\"language-cpp\">#include &lt;iostream&gt;\nusing namespace std;\n\nint main(){\n int a,b;\n cin&gt;&gt;a;\n \n int n&#61;1,count&#61;1,num&#61;1;\n \n for(int i&#61;0;i&lt;a;i&#43;&#43;)\n {\n     if(count &gt; n)\n     {\n         num&#43;&#61;2;\n         n&#43;&#43;;\n         count&#61;1;\n         i--;\n     }\n     else\n     {\n        cout &lt;&lt; num &lt;&lt; &#34;,&#34;;    //输出整个数列\n        count&#43;&#43;;\n     }\n }\n cout &lt;&lt; endl;\n \n \n cout &lt;&lt; num;\n \n return 0;\n}</code></pre>\n\n<p> </p>\n",
  "tag_name": "c语言",
  "cpp": "#include <iostream>\nusing namespace std;\nint main(){\n\tint a,b;\n\tcin>>a;\n\tint n=1,count=1,num=1;\n\tfor(int i=0;i<a;i++)\n\t{\n\t\tif(count > n)\n\t\t{\n\t\t\tnum+=2;\n\t\t\tn++;\n\t\t\tcount=1;\n\t\t\ti--;\n\t\t}\n\t\telse\n\t\t{\n\t\tcout << num << \",\";\t\n\t\tcount++;\n\t\t}\n\t}\n\tcout << endl;\n\tcout << num;\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470254",
  "status": 1,
  "keywords": "算法高阶,数论算法,算法问题选编,整数的因子分解",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/19.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "u011093126"
每日一练社区's avatar
test  
每日一练社区 已提交
19
}