hiho week 100 register

Ended

Participants:432

Verdict:Accepted
Score:100 / 100
Submitted:2016-05-30 15:51:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
 
int mark[40320*9+1];
bool used[10];
 
const int fac[9]={1,1,2,6,24,120,720,5040,40320};
 
 
int contor(int *a){
    int temp,num=0;
    for(int i=0;i<8;i++){
        temp=0;
        for(int j=i+1;j<9;j++)
            if(a[i]>a[j]) temp++;
        num+=temp*fac[8-i];
    }
    return num;
}
void inv(int n,int *a){
    memset(used,false,sizeof(used));
    for(int i=0;i<8;i++){
        int w=n/fac[8-i];
        n%=fac[8-i];
        for(int j=1,cnt=0;j<=9;j++) {
            if(!used[j]) {
                cnt++;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX