zoukankan      html  css  js  c++  java
  • NYOJ 139 我排第几个

     1 #include<iostream>
     2 #include<string>
     3 #include<memory.h>
     4 using namespace std;
     5 int Jc[13] = {0,1};
     6 bool mark[13];
     7 int main()
     8 {
     9 //    freopen("in.txt","r",stdin);
    10     char ch;
    11     int k,i,j,s,t;
    12     for(i = 2; i < 13; ++i)
    13         Jc[i] = Jc[i-1] * i;
    14     cin>>t;
    15     while(t--)
    16     {
    17         s = 0;
    18         memset(mark,0,sizeof(mark));
    19         for(i=0; i<12; ++i)
    20         {
    21             cin>>ch;
    22             k = 0;
    23             int x = ch - 'a' + 1;
    24             mark[x] = 1;
    25             for(j = 1; j < x; ++j)
    26                 if(!mark[j])
    27                     ++k;
    28             s += k * Jc[11-i];
    29         }
    30         cout<<s+1<<endl;
    31     }
    32     return 0;
    33 }
  • 相关阅读:
    BZOJ 3033 太鼓达人(DFS+欧拉回路)
    HDU 5121 Just A Mistake
    HDU 5120 Intersection
    HDU 5119 Happy Matt Friends
    HDU 5117 Fluorescent
    BZOJ 1088: [SCOI2005]扫雷Mine
    Codeforces 994 C
    BZOJ 2242: [SDOI2011]计算器
    HDU 4609 3-idiots
    算法笔记--FFT && NTT
  • 原文地址:https://www.cnblogs.com/yaling/p/3030957.html
Copyright © 2011-2022 走看看