zoukankan      html  css  js  c++  java
  • ( m LightOJ 1371

    http://www.lightoj.com/volume_showproblem.php?problem=1371

    题意:给你n根竹子,和n只熊猫(XD),每个熊猫只能选择重量不大于它的竹子,问有几种情况。

    思路:简单的组合,先对竹子和熊猫排序,每个熊猫能够选择的竹子是有限的,到i+1个熊猫时,由于前面i个熊猫已经选了竹子,故不比它重的竹子t,t-i+1即它能选的种类数,乘法原理即可。

    之前看错题目以为【重量相同的竹子都认为是相同的】。

     

    /** @Date    : 2016-12-02-19.55
      * @Author  : Lweleth (SoungEarlf@gmail.com)
      * @Link    : https://github.com/
      * @Version :
      */
    
    #include<bits/stdc++.h>
    #define LL long long
    #define PII pair<int ,int>
    #define MP(x, y) make_pair((x),(y))
    #define fi first
    #define se second
    #define PB(x) push_back((x))
    #define MMG(x) memset((x), -1,sizeof(x))
    #define MMF(x) memset((x),0,sizeof(x))
    #define MMI(x) memset((x), INF, sizeof(x))
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    const int N = 1e5+2000;
    const LL mod = 1000000007;
    
    int a[1010], b[1010];
    int main()
    {
        int T;
        int cnt = 0;
        cin >> T;
        while(T--)
        {
            int n;
            scanf("%d", &n);
            for(int i = 1; i <= n; i++)
                scanf("%d", a + i);
            for(int i = 1; i <= n; i++)
                scanf("%d", b + i);
    
            sort(a + 1, a + 1 + n);
            sort(b + 1, b + 1 + n);
    
            int p = 1;
            int t = 0;
            LL ans = 1;
            for(int i = 1; i <= n; i++)
            {
                t = 0;
                for(int j = 1; j <= n; j++)
                {
                    if(a[j] <= b[i])
                        t++;
                    else if(t == 0)
                    {
                        ans = 0;
                        break;
                    }
                }
                ans *= (LL)(t - i + 1);
                ans %= mod;
                //cout << ans;
    
            }
            printf("Case %d: %lld
    ", ++cnt, ans);
        }
        return 0;
    }
    
    
  • 相关阅读:
    poj3083(Children of the Candy Corn)
    poj3278(Catch That Cow)
    poj2996(Help Me with the Game)
    poj2993(Emag eht htiw Em Pleh)
    js 对多sheet Excel赋值操作
    学习进度总结(三)
    学习进度总结(二)
    学习进度总结(一)
    《人月神话》阅读笔记(1)
    Android studio的安装与使用
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/6131725.html
Copyright © 2011-2022 走看看