{
  "question_id": 6722211,
  "question_title": "怎么求尾数与常数之和？",
  "question_content": "<p>数列的前3项都为1&#xff0c;从第4项开始&#xff0c;每项都是其前3项的和&#xff1a;1, 1, 1, 3, 5, 9, 17, … 请你编程求出数列第N项的<strong>4位尾数</strong>与90000之和。输入一个正整数N&#xff0c;输出所求的和。</p>",
  "difficulty": "简单",
  "answer_id": 47620887,
  "answer_content": "<p>#include&lt;iostream&gt;</p>\n\n<p>#include&lt;cstring&gt;</p>\n\n<p>#include&lt;cstdio&gt;</p>\n\n<p>#include&lt;cstdlib&gt;</p>\n\n<p>#include&lt;cmath&gt;</p>\n\n<p>#include&lt;iomanip&gt;</p>\n\n<p>#include&lt;algorithm&gt;</p>\n\n<p>#include&lt;set&gt;</p>\n\n<p>using namespace std;</p>\n\n<p>#define NUM 10000//符号常量</p>\n\n<p>long long dp[1000000];</p>\n\n<p>int main(){<!-- --></p>\n\n<p>    //freopen(&#34;E:\\\\VSCode_C&#43;&#43;\\\\test.txt&#34;,&#34;r&#34;,stdin);</p>\n\n<p>    int n;</p>\n\n<p>    cin&gt;&gt;n;</p>\n\n<p>    dp[1]&#61;1;</p>\n\n<p>    dp[2]&#61;1;</p>\n\n<p>    dp[3]&#61;1;</p>\n\n<p>    for(int i&#61;4;i&lt;&#61;n;i&#43;&#43;){<!-- --></p>\n\n<p>        dp[i]&#61;dp[i-1]&#43;dp[i-2]&#43;dp[i-3];</p>\n\n<p>    }</p>\n\n<p>    cout&lt;&lt;dp[n]&lt;&lt;endl;</p>\n\n<p>    long long x&#61;dp[n]%10000&#43;9000;</p>\n\n<p>    cout&lt;&lt;x;</p>\n\n<p>    system(&#34;pause&#34;);</p>\n\n<p>    return 0;</p>\n\n<p>}</p>",
  "tag_name": "c语言",
  "cpp": "#include <iostream>\n#include <cstring>\n#include <cstdio>\n#include <cstdlib>\n#include <cmath>\n#include <iomanip>\n#include <algorithm>\n#include <set>\nusing namespace std;\n#define NUM 10000\nlong long dp[1000000];\nint main(){\n    int n;\n    cin>>n;\n    dp[1]=1;\n    dp[2]=1;\n    dp[3]=1;\n    for(int i=4;i<=n;i++){\n        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];\n    }\n    cout<<dp[n]<<endl;\n    long long x=dp[n]%NUM+90000;\n    cout<<x;\n    system(\"pause\");\n    return 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470143",
  "status": 1,
  "keywords": "数列",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/11.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "feiniao2029"
}