I am in the first few time limits: ms | Memory limit:65535 KB Difficulty:3
-
Describe
-
Now there are "ABCDEFGHIJKL" 12 characters, all of which are arranged in a dictionary order, give any sort of arrangement, say this arrangement in all permutations is the number of small?
-
-
Input
-
The
-
first line has an integer n (0<n<=10000);
Then there are n rows, each line being an arrangement;
-
-
Output
-
-
outputs an integer m, one row, and M indicates the number of permutations;
-
-
Sample input
-
-
3abcdefghijklhgebkflacdjigfkedhjblcia
-
-
Sample output
-
-
1302715242260726926
-
-
Source
-
-
[Miao Building] Original
-
-
Uploaded by
-
-
Miao-dong building
-
-
Meng B;
-
#include <cstdio>#include<cstring>inta[ the];voiddeal () {a[1]=1; for(intI=2; i<= A; i++) A[i]=a[i-1]*i;}intMain () {deal (); intT;SCANF ("%d", &t); while(t--) { Charstr[ the]; scanf ("%s", str);intlen=strlen (str); intREC =0; for(intI=0; i<len; i++) { intCount=0; for(intj=i+1; j<len; J + +) if(Str[j]<str[i]) count++; Rec+ = count*a[len-1-i]; } printf ("%d\n", rec+1); } return 0;}
#include <cstdio>#include<cstring>intjc[ -]={0,1,2,6, -, -,720,5040,40320,362880,3628800,39916800,479001600};intMain () {Charnormal[ -]="ABCDEFGHIJKL"; intT scanf"%d", &t); while(t--) { intv[ -]; memset (V,0,sizeof(v)); Charstr[ -]; scanf"%s", str); intlen=strlen (str); intsum=0; for(intI=0; i<len; i++) {V[str[i]-'a']=1; if(str[i]-normal[i]==0) { Continue; } Else { intD=0;intp=str[i]-'a'; for(intk=p-1; k>=0; k--) if(v[k]==0) d++; intj=i+1; intt= A-J; //printf ("%d\n", j+t);sum=sum+d*Jc[t]; }} printf ("%d\n", sum+1); } return 0;}
falied
nyoj139--I rank (comtop unfold)