http://acm.nyist.net/JudgeOnline/problem.php?pid=139

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 int jiecheng(int x)
 4 {
 5     int jie=1;
 6     for(int i=2;i<=x;i++)
 7     jie*=i;
 8     return jie;
 9 }
10 int main()
11 {
12     int t;
13     int len;
14     char ch;
15     char str[13];
16     scanf("%d",&t);
17     while(t--)
18     {
19         scanf("%s",str);
20         len=strlen(str);
21         int sum=0;
22         for(int i=len-1;i>=0;i--)
23         {
24             ch=str[i];
25             int count=0;
26             for(int j=len-1;j>i;j--)
27             {
28                 if(ch>str[j]) count++;
29             }
30             sum+=count*jiecheng(len-1-i);
31             //printf("%d\n",sum);
32         }
33         printf("%d\n",sum+1);
34     }
35 }

 

相关文章:

  • 2021-08-01
  • 2022-02-05
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2022-12-23
猜你喜欢
  • 2022-01-04
  • 2021-11-10
  • 2022-12-23
  • 2021-11-08
  • 2022-02-19
  • 2022-02-01
  • 2021-07-19
相关资源
相似解决方案