Description
There are n swords of different weights Wiand n heros of power Pi.
Your task is to find out how many ways the heros can carry the swords so that each hero carries exactly one sword.
Here are some rules:
(1) Every sword is carried by one hero and a hero cannot carry a sword whose weight is larger than his power.
(2) Two ways will be considered different if at least one hero carries a different sword.
Input
The first line of the input gives the number of test cases T(1 ≤ T ≤ 50).
Each case starts with a line containing an integer n (1 ≤ n ≤ 105) denoting the number of heros and swords.
The next line contains n space separated distinct integers denoting the weight of swords.
The next line contains n space separated distinct integers denoting the power for the heros.
The weights and the powers lie in the range [1, 109].
Output
For each case, output one line containing "Case #x: " followed by the number of ways those heros can carry the swords.
This number can be very big. So print the result modulo 1000 000 007.
Sample Input
3 5 1 2 3 4 5 1 2 3 4 5 2 1 3 2 2 3 2 3 4 6 3 5
Sample Output
Case #1: 1 Case #2: 0 Case #3: 4 当前人能拿的当前剑,之前的情况。 HUST VJ可以用long long - -#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define mod 1000000007 #define L long long using namespace std; L w[100010],p[100010]; int main() { int n,m,i,j,cla; ios::sync_with_stdio(false); cin>>cla; for(int k=1;k<=cla;k++) { cin>>n; for(i=0;i<n;i++) cin>>w[i]; for(i=0;i<n;i++) cin>>p[i]; sort(w,w+n); sort(p,p+n); printf("Case #%d: ",k); L ans=1; j=0; for(i=0;i<n;i++)//枚举各个剑的重量是否在当前人所承受的范围之内若是j-i然后垒成在ans { while(j<n&&w[j]<=p[i]) { j++; } ans=ans*(j-i)%mod; } printf("%lld\n",ans); } return 0; }
本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、动画、3D空间视频等,旨在为开发者提供全面的游戏开发知识和实践经验。
1217

被折叠的 条评论
为什么被折叠?



