{
"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=1045\">简单数列5</a><br />\n<strong> </strong>已知一数列:1,3,3,5,5,5,7,7,7,7,9,9,9,9,9,11,11,11,11,11,11,11.....请根据规律求出第n项的值。例如:n=4 项时,其值为5,n=11时,其值为9.\n<strong>输入格式 </strong>一个自然数n,(0<n<1000)<br />\n<br />\n<strong>输出格式</strong> 一个整数,即第n项的值。<br />\n<strong>样例输入:4</strong><br />\n<strong>样例输出 :5</strong></p>\n", "difficulty": "简单", "answer_id": 53441264, "answer_content": "<pre>\n<code class=\"language-cpp\">#include <iostream>\nusing namespace std;\n\nint main(){\n int a,b;\n cin>>a;\n \n int n=1,count=1,num=1;\n \n for(int i=0;i<a;i++)\n {\n if(count > n)\n {\n num+=2;\n n++;\n count=1;\n i--;\n }\n else\n {\n cout << num << ","; //输出整个数列\n count++;\n }\n }\n cout << endl;\n \n \n cout << 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"
}