• SDNU 1245.这题超难的,建议先做其他的,看都不要看(思维)


    Description

    求组合数C(n,m)

    Input

    T(0 < T < 2000)
    每组样例两个数n, m(0 < n, m< 60)
     

    Output

    C(n,m)

    Sample Input

    2
    1 1
    2 1

    Sample Output

    1
    2

    Source

    Unknown
    思路:真是一道神奇的题啊,我想着用常规的办法去求解,但是爆了long long也不自知,真是傻。然后用了优化。
    #include <cstdio>
    #include <iostream>
    #include <cmath>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <map>
    using namespace std;
    #define ll long long
    
    int t, n, m;
    ll sum1;
    
    int main()
    {
        scanf("%d", &t);
        while(t--)
        {
            sum1 = 1;
            scanf("%d%d", &n, &m);
            for(int i = 1; i <= m; i++)
            {
                sum1 *= (n-i+1);
                sum1 /= i;
            }
            printf("%lld
    ", sum1);
        }
        return 0;
    }
  • 相关阅读:
    ctrl+shift+k取消
    ERROR 1872
    swap
    mysql主从跳过错误
    undo
    gtid
    falcon监控指标
    连接数
    datetime与timestamp相互转换
    截取文件内容
  • 原文地址:https://www.cnblogs.com/RootVount/p/10991748.html
Copyright © 2020-2023  润新知