結果
問題 | No.398 ハーフパイプ(2) |
ユーザー |
![]() |
提出日時 | 2020-04-15 19:01:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 1,895 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-01 18:58:41 |
合計ジャッジ時間 | 1,781 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
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()