[NOIP 1998 普及组] 阶乘之和

Luogu
IDLGP1009
Time1000ms
Memory125MB
DifficultyP2
数学高精度1998NOIP 普及组
用高精度计算出 $S = 1! + 2! + 3! + \cdots + n!$($n \le 50$)。 其中 `!` 表示阶乘,定义为 $n!=n\times (n-1)\times (n-2)\times \cdots \times 1$。例如,$5! = 5 \times 4 \times 3 \times 2 \times 1=120$。 ## Input 一个正整数 $n$。 ## Output 一个正整数 $S$,表示计算结果。 [samples] ## Note **【数据范围】** 对于 $100 \%$ 的数据,$1 \le n \le 50$。 **【其他说明】** 注,《深入浅出基础篇》中使用本题作为例题,但是其数据范围只有 $n \le 20$,使用书中的代码无法通过本题。 如果希望通过本题,请继续学习第八章高精度的知识。 NOIP1998 普及组 第二题
Samples
Input #1
3
Output #1
9
API Response (JSON)
{
  "problem": {
    "name": "[NOIP 1998 普及组] 阶乘之和",
    "description": {
      "content": "用高精度计算出 $S = 1! + 2! + 3! + \\cdots + n!$($n \\le 50$)。 其中 `!` 表示阶乘,定义为 $n!=n\\times (n-1)\\times (n-2)\\times \\cdots \\times 1$。例如,$5! = 5 \\times 4 \\times 3 \\times 2 \\times 1=120$。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 128000
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP1009"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "用高精度计算出 $S = 1! + 2! + 3! + \\cdots + n!$($n \\le 50$)。\n\n其中 `!` 表示阶乘,定义为 $n!=n\\times (n-1)\\times (n-2)\\times \\cdots \\times 1$。例如,$5! = 5 \\times 4 \\times 3 \\times 2 \\times 1=120$。\n\n## Input\n\n一个正整数 $n$。\n\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments