hiho week 100 register

Ended

Participants:432

Verdict:Accepted
Score:100 / 100
Submitted:2016-06-02 12:39:54

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 <iostream>
#include <vector>
#include <list>
#include <queue>
#include <math.h>
using namespace std;
int factorial[9] = { 1 };
const int number[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
const int dir[4][2] = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };
inline int fact(int k)
{
    return factorial[k];
}
int num2order(int val)
{
    int n[9];
    for (int i = 8, v = val; i >= 0; i--, v /= 10) {
        n[i] = v % 10;
    }
    int a[9] = { 0 };
    int k = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = i + 1; j < 9; j++) {
            if (n[j] < n[i])
                a[i]++;
        }
        k += a[i] * fact(8 - i);
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX