nyoj139--I rank (comtop unfold)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.