TC srm.673 300
Time Limit:20 Sec
Memory limit:256 MB
Topic Connection
Description
Give you n (n<=50) horse and n person, a horse and a person can form a cavalry, this cavalry's fighting power equals the combat effectiveness of the horse, ask you how many combinations of ways to meet the other cavalry's combat effectiveness is no more than the No. 0 cavalry.
Input
Output
Sample Input
Sample Output
HINT
Test instructions
Exercises
Probably on the violence enumeration which horse and the No. 0 match, the cavalry behind us according to the combat effectiveness from the big to the small after the order, for each cavalry two points (or violence) to find the maximum number of horses can be selected, and then can be a little bit to do it!
Code
#include <stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespacestd;Const intMoD = 1e9+7;BOOLcmpintAintb) { returnA>b;}classbearcavalry{ Public: intCountassignments (Vector <int> Warriors, Vector <int>horses) {Sort (Warriors.begin ()+1, Warriors.end (), CMP); Sort (Horses.begin (), Horses.end ()); Long LongAns =0; for(intI=0; I) {sort (Horses.begin (), Horses.end ()); intp = warriors[0]*Horses[i]; intK =Horses[i]; Horses.erase (Horses.begin ()+i); Long LongAns2 =1; intFlag =0; for(intj=1; J<warriors.size (); j + +) { Long LongTMP =-1; for(intt=0; T) { if(warriors[j]*horses[t]>=p) Break; TMP=T; } //cout<<i<< "" <<j<< "" <<tmp<<endl;TMP = tmp +2-J; //cout<<i<< "" <<j<< "" <<tmp<<endl; if(tmp<=0) {flag=1; Break; } ans2= (ANS2 * tmp)%MoD; } if(flag==0) ans= (ans + ans2)%MoD; Horses.push_back (k); } returnans; }};intMain () {bearcavalry C; Vector<int>A; Vector<int>b; A.push_back (5); A.push_back (8); A.push_back (4); A.push_back (8); B.push_back ( +); B.push_back ( +); B.push_back ( -); B.push_back ( -); printf ("%d\n", C.countassignments (A, b));}
TC SRM 673 Div1