标签:pre 自己的 file turn clu range 分享图片 临时 otto
1 #include <cstdio> 2 3 long long dp[22]; 4 5 long long range(long long n, long long m) 6 { 7 if (m > n / 2) 8 m = n - m; 9 long long sum = 1; 10 if (!m) 11 return 1; 12 for (long long i = 1; i <= m; i++) 13 { 14 sum *= n--; 15 sum /= i; 16 } 17 return sum; 18 } 19 20 int main() 21 { 22 long long n, m; 23 int t; 24 dp[1] = 0; 25 dp[2] = 1; 26 dp[3] = 2; 27 for (long long i = 4; i <= 21; i++) 28 { 29 dp[i] = (i - 1)*(dp[i - 2] + dp[i - 1]); 30 } 31 32 scanf("%d", &t); 33 while (t--) 34 { 35 scanf("%lld%lld", &n, &m); 36 printf("%lld\n", range(n, m)*dp[m]); 37 } 38 return 0; 39 }
简单的dp
Description
Input
Output
Sample Input
Sample Output
标签:pre 自己的 file turn clu range 分享图片 临时 otto
原文地址:https://www.cnblogs.com/fhzy291146030/p/9298331.html