# 次方與階乘 https://neoj.sprout.tw/problem/891/ ### 題目敘述 請讀入兩個數字n, m,並輸出$n^m + n!/m!$ ### 輸入說明 輸入有兩個正整數n, m $1≤n≤10$ $0≤m≤5$,且$m≤n$ ### 輸出說明 請輸出"$n^m(n的m次方) + n!/m!$" 注意:請記得考慮m=0的情況(0!=1) ### 範例輸入 ``` 5 3 ``` ### 範例輸出 ``` 145 ``` # Code ```cpp #include <iostream> using namespace std; int main(){ int n, m, x = 1, N = 1, M = 1; cin >> n >> m; for (int t=0 ; t<m ; t++) { x *= n; } for (int t=0 ; t<n ; t++) { N *= (t + 1); } for (int k=0 ; k<m ; k++) { M *= (k + 1); } cout << x + N / M << "\n"; } ```