結果

問題 No.398 ハーフパイプ(2)
ユーザー mkawa2mkawa2
提出日時 2020-04-15 19:01:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,895 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-09 18:56:13
合計ジャッジ時間 1,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 27 ms
11,008 KB
testcase_02 AC 80 ms
11,008 KB
testcase_03 AC 81 ms
11,136 KB
testcase_04 AC 82 ms
11,008 KB
testcase_05 AC 34 ms
11,008 KB
testcase_06 AC 35 ms
11,008 KB
testcase_07 AC 59 ms
11,008 KB
testcase_08 AC 29 ms
11,008 KB
testcase_09 AC 42 ms
11,008 KB
testcase_10 AC 39 ms
11,008 KB
testcase_11 AC 33 ms
11,008 KB
testcase_12 AC 55 ms
11,008 KB
testcase_13 AC 55 ms
11,008 KB
testcase_14 AC 59 ms
11,008 KB
testcase_15 AC 29 ms
11,008 KB
testcase_16 AC 55 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    fac=[1]
    for i in range(1,7):fac.append(fac[-1]*i)
    memo={}
    def p(*aa):
        t=tuple(aa)
        if t in memo:return memo[t]
        s=sum(aa)
        res=1
        for a in aa[:-1]:
            res*=nCr(s,a)
            s-=a
        memo[t]=res
        return res

    def nCr(n,r):
        return fac[n]//fac[r]//fac[n-r]

    av=float(input())
    s=int(av*4+0.5)
    ans=0
    for a in range(max(0,s-300),101):
        for b in range(max(a,s-a-200),101):
            for c in range(max(b,s-a-b-100),101):
                d=s-a-b-c
                if d<c:break
                if a==b==c==d:ans+=a*(100-a)*p(1,1,4)+(100-a)*p(1,5)+a*p(1,5)+1
                elif a==b==c:ans+=a*(100-d)*p(1,1,1,3)+(100-d)*p(1,1,4)+a*p(1,2,3)+p(2,4)
                elif b==c==d:ans+=a*(100-d)*p(1,1,1,3)+(100-d)*p(1,2,3)+a*p(1,1,4)+p(2,4)
                elif a==b and c==d:ans+=a*(100-d)*p(1,1,2,2)+(100-d)*p(1,2,3)+a*p(1,2,3)+p(3,3)
                elif a==b:ans+=a*(100-d)*p(1,1,1,1,2)+(100-d)*p(1,1,1,3)+a*p(1,1,2,2)+p(1,2,3)
                elif b==c:ans+=a*(100-d)*p(1,1,1,1,2)+(100-d)*p(1,1,2,2)+a*p(1,1,2,2)+p(2,2,2)
                elif c==d:ans+=a*(100-d)*p(1,1,1,1,2)+(100-d)*p(1,1,2,2)+a*p(1,1,1,3)+p(1,2,3)
                else:ans+=a*(100-d)*p(1,1,1,1,1,1)+(100-d)*p(1,1,1,1,2)+a*p(1,1,1,1,2)+p(1,1,2,2)
    print(ans)

main()
0