結果

問題 No.1311 Reverse Permutation Index
ユーザー 37zigen37zigen
提出日時 2020-12-18 22:16:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 10,220 KB
最終ジャッジ日時 2023-10-21 08:25:07
合計ジャッジ時間 933 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 30 ms
10,108 KB
testcase_05 WA -
testcase_06 AC 30 ms
10,108 KB
testcase_07 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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.pop(num.index(b[i]))
print(ans)
0