結果
問題 |
No.1311 Reverse Permutation Index
|
ユーザー |
|
提出日時 | 2020-12-18 22:18:36 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 1,500 ms |
コード長 | 389 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-21 09:27:14 |
合計ジャッジ時間 | 872 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 |
ソースコード
import math N, S = map(int, input().split()) a = [] num = list(range(S)) for i in range(S): id = N // math.factorial(S - 1 - i) N %= math.factorial(S - 1 - i) a.append(num.pop(id)) b = [-1] * S for i in range(S): b[a[i]] = i num = list(range(S)) ans = 0 for i in range(S): ans += math.factorial(S - 1 - i) * num.index(b[i]) del num[(num.index(b[i]))] print(ans)