s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s903954589
p03776
u191829404
1560119978
Python
Python (3.4.3)
py
Runtime Error
192
14984
1342
import math import copy from operator import mul from functools import reduce from collections import defaultdict from collections import Counter from collections import deque # 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B) from itertools import product # 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n) from itertools import permutations # 組み合わせ {}_len(seq) C_n: combinations(seq, n) from itertools import combinations from bisect import bisect_left, bisect_right # import numpy as np # from scipy.special import perm from scipy.special import comb def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W # 四方向: 右, 下, 左, 上 dy = [0, -1, 0, 1] dx = [1, 0, -1, 0] def i_inpl(): return int(input()) def l_inpl(): return list(map(int, input().split())) INF = float("inf") ######## N, A, B = l_inpl() v = l_inpl() sort_v = sorted(v, reverse=True) ans_1 = sum(sort_v[:A])/A print(ans_1) max_v = sort_v[A-1] max_v_count = sort_v.count(max_v) max_v_count_in_ans = sort_v[:A].count(max_v) if max_v != sort_v[0]: # 1つでも増やすと平均が減少する場合 ans = comb(max_v_count, max_v_count_in_ans) else: ans = 0 for i in range(A, min(B, max_v_count) + 1): ans += comb(max_v_count, i) print(int(ans))
s203951172
p03776
u885899351
1559866070
Python
Python (3.4.3)
py
Runtime Error
19
3064
525
def pascal(n,r): global p while len(p)<50: pi=[1] for i in range(len(p)): pi.append(p[-1][i]+p[-1][i+1]) pi.append(1) p.append(pi) return p[n-1][r] n,a,b=map(int,input().split()) v=sorted(list(map(int,input().split())))[::-1] va=v[:a] val=va[-1] print(sum(va)/a) p=[[1,1]] if len(set(va))>1: print(pascal(v.count(val),va.count(val))) elif v.count(val)==1: print(1) else: m=v.count(val) x=0 for i in range(a,b+1): x+=pascal(m,i) print(x)
s775739971
p03776
u885899351
1559866027
Python
Python (3.4.3)
py
Runtime Error
18
3064
524
def pascal(n,r): global p while len(p)<n: pi=[1] for i in range(len(p)): pi.append(p[-1][i]+p[-1][i+1]) pi.append(1) p.append(pi) return p[n-1][r] n,a,b=map(int,input().split()) v=sorted(list(map(int,input().split())))[::-1] va=v[:a] val=va[-1] print(sum(va)/a) p=[[1,1]] if len(set(va))>1: print(pascal(v.count(val),va.count(val))) elif v.count(val)==1: print(1) else: m=v.count(val) x=0 for i in range(a,b+1): x+=pascal(m,i) print(x)
s652783535
p03776
u102960641
1558795129
Python
Python (3.4.3)
py
Runtime Error
23
3572
593
from functools import reduce from operator import mul import bisect def cmb(n, r): r = min(n - r, r) if r == 0: return 1 return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1)) n,a,b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse = True) if v[0] == v[a-1]: print(v[0]) c = v.count(v[a-1]) ans = 0 for i in range(a,b+1): ans += cmb(c,i) print(ans) else: print(sum(v[:a]) / a) c = v.count(v[a-1]) d = 0 for key,value in enumerate(v): if value == v[a-1]: d = key break print(cmb(c,a-d))
s978520903
p03776
u798129018
1558377284
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38768
785
from itertools import* from math import* from collections import* from heapq import* from bisect import bisect_left,bisect_right from copy import deepcopy inf = 10**18 mod = 10**9+7 from functools import reduce import sys sys.setrecursionlimit(10**7) def comb(n,r): return factorial(n)//(factorial(n-r)*factorial(r)) n,a,b = map(int,input().split()) v = list(map(int,input().split())) v.sort(reverse=True) max_mean = sum(v[0:a])/a print(max_mean) #選び方の総数を求める c = Counter(v) i = 0 num = 0 ans = 0 while num<=a: if num+c[v[i]]>=a: num += c[v[i]] else: i +=1 num += c[v[i]] if i > 0: ans += comb(c[v[i]],a) print(ans) else: for i in range(a,b+1): if c[v[0]] >=i: ans += comb(c[v[0]],i) print(ans)
s014997013
p03776
u365364616
1556567172
Python
Python (3.4.3)
py
Runtime Error
19
3064
840
def value_and_count(x): d = {} for xi in x: if xi in d.keys(): d[xi] += 1 else: d[xi] = 1 return d def comb(n, k): k = min(n - k, k) denominator = 1 # 分母 numerator = 1 # 分子 for i in range(k): denominator *= i + 1 numerator *= n - i return numerator // denominator n, a, b = map(int, input().split()) v = list(map(int, input().split())) d_v = value_and_count(v) v.sort(reverse=True) sum_v = sum(v[:a]) print(sum_v / a) ans = 0 d_vk = None for k in range(a, b + 1): vk = v[:k] sum_vk = sum(vk) if sum_vk < sum_v: break if d_vk is None: d_vk = value_and_count(vk) else: d_vk[vk[-1]] += 1 ans_k = 1 for vi, ci in d_vk.items(): ans_k *= comb(d_v[vi], ci) ans += ans_k print(ans)
s678837947
p03776
u041075929
1555781387
Python
Python (3.4.3)
py
Runtime Error
75
3912
723
import sys, os f = lambda:list(map(int,input().split())) if 'local' in os.environ : sys.stdin = open('./input.txt', 'r') def fac(n): if n== 1 or n == 0: return 1 return n * fac(n-1) def comb(n, k): return fac(n)/(fac(k) * fac(n-k)) def solve(): n, a, b = f() v = f() v = sorted(v, reverse = True) c = v[a-1] cnt1 = 0 total = 0 for i in range(n): if v[i] == c: total += 1 if i < a: cnt1 += 1 print("{:.7f}".format(sum(v[0:a])/a)) if v[0] == c: ans = 0 for i in range(a, b+1): ans += comb(total, i) print(ans) else: print(int(comb(total, cnt1))) solve()
s646576185
p03776
u879581330
1555260354
Python
Python (3.4.3)
py
Runtime Error
17
2940
919
#include <bits/stdc++.h> using namespace std; long long Combination(int n, int r) { vector<vector<long long>> C(n + 1, vector<long long>(n + 1, 1)); for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; return C[n][r]; } int main() { int N, A, B; cin >> N >> A >> B; vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i]; sort(v.begin(), v.end(), greater<int>()); double ans1 = 0; for (int i = 0; i < A; i++) ans1 += v[i]; ans1 /= A; long long ans2 = 0; if (v[0] == v[A - 1]) { int n = 0; for (int i = 0; i < N; i++) if (v[i] == v[0]) n++; for (int r = A; r <= B; r++) ans2 += Combination(n, r); } else { int n = 0, r = 0; for (int i = 0; i < N; i++) if (v[i] == v[A - 1]) n++; for (int i = 0; i < A; i++) if (v[i] == v[A - 1]) r++; ans2 = Combination(n, r); } cout << fixed << ans1 << endl << ans2 << endl; }
s012353826
p03776
u813102292
1554584055
Python
Python (3.4.3)
py
Runtime Error
74
3916
555
def fuct(n:int)->int: if n==1: return 1 else: return n * fuct(n-1) def main(): n,a,b = map(int, input().split()) v = list(map(int, input().split())) v = sorted(v, reverse=True) print(sum(v[:a])/a) res = 0 if v[0]==v[a-1]: vn = v.count(v[0]) for r in range(a,b+1): res += fuct(vn)//(fuct(vn-r) * fuct(r)) else: vn = v.count(v[a-1]) r = v[:a].count(v[a-1]) res += fuct(vn)//(fuct(vn-r) * fuct(r)) print(res) if __name__ == '__main__': main()
s352883266
p03776
u268516119
1553742991
Python
Python (3.4.3)
py
Runtime Error
17
2940
168
import math N=int(input()) for i in reversed(range(1,math.ceil(math.sqrt(N))+1)): if N%i==0: B=N//i print(math.floor(math.log10(B))+1) break
s904692793
p03776
u572144347
1553691568
Python
PyPy3 (2.4.0)
py
Runtime Error
205
45552
649
N, A, B = map(int, input().split()) V = list(map(int, input().split())) V.sort(reverse=True) mean = sum(V[:A]) / A mean = float(mean) print(mean) def fact(n): if n == 0 or n == 1: return 1 return fact(n-1) * n def comb(n,a): return fact(n)//fact(a)//fact(n-a) from collections import Counter c = Counter(V) n = c[V[0]] if V[0] != V[A-1]: n = c[V[A-1]] if n > 1: idx = V.index[V[A-1]] _A = A - idx print( comb( n, _A ) ) # print(n); exit() else: print(1); exit() if V[0] == V[A-1]: ans = 0 for i in range(A, min(n+1, B+1)): ans += comb(n, i) print( ans )
s144953623
p03776
u572144347
1551447757
Python
Python (3.4.3)
py
Runtime Error
17
3060
394
N,A,B=map(int,input().split()) V=list(map(int,input().split())) V=sorted(V,reverse=True) def fac(n): if n<= 1: return 1 return n*fac(n-1) def c (a,b): if b==0: return 1 return fac(a)//fac(b)//fac(a-b) print(sum(V[:A])/A) if V.count(V[0]) >= A: ans=0 for i in range(A, min(B+1,V.count(V[A])+1))): ans+=c(V.count(V[A]),i) else: lstcnt=A-1 ans=V.count(V[A]) print(ans)
s741698706
p03776
u572144347
1551447072
Python
Python (3.4.3)
py
Runtime Error
18
3060
380
N,A,B=map(int,input().split()) V=list(map(int,input().split())) V=sorted(V,reverse=True) def fac(n): if n== 1: return 1 return n*fac(n-1) def c (a,b): if b==0: return 1 return fac(a)//fac(b)//fac(a-b) print(sum(V[:A])/A) if V.count(V[A]) >= A: ans=0 for i in range(A, min(B+1,V.count(V[A])+1))): ans+=c(V.count(V[A]),i) else: ans=V.count(V[A]) print(ans)
s786107828
p03776
u255280439
1550811603
Python
Python (3.4.3)
py
Runtime Error
17
2940
1024
aimport sys import collections def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def main(): N, A, B = [int(_) for _ in sys.stdin.readline().split()] V = sorted([int(_) for _ in sys.stdin.readline().split()], reverse=True) D = collections.defaultdict(lambda: 0) ans = 0 for v in V: D[v] += 1 for C in range(A, B+1): if (sum(V[:C]) / C) == (sum(V[:A]) / A): ans += comb(D[V[C-1]], V[:C].count(V[C-1])) print((sum(V[:A]) / A)) print(ans) main()
s715528844
p03776
u255280439
1550811426
Python
Python (3.4.3)
py
Runtime Error
17
3064
345
import sys N, A, B = [int(_) for _ in sys.stdin.readline().split()] V = sorted([int(_) for _ in sys.stdin.readline().split()], reverse=True) D = collections.defaultdict(lambda: 0) ans = 0 for C in range(A, B+1): if (sum(V[:C]) / C) == (sum(V[:A]) / A): ans += comb(V.count(V[C-1]), V[:C].count(V[C-1])) print(sum(V[:A]) / A) print(ans)
s117784934
p03776
u255280439
1550811367
Python
Python (3.4.3)
py
Runtime Error
18
3064
399
def main(): N, A, B = [int(_) for _ in sys.stdin.readline().split()] V = sorted([int(_) for _ in sys.stdin.readline().split()], reverse=True) D = collections.defaultdict(lambda: 0) ans = 0 for C in range(A, B+1): if (sum(V[:C]) / C) == (sum(V[:A]) / A): ans += comb(V.count(V[C-1]), V[:C].count(V[C-1])) print(sum(V[:A]) / A) print(ans) main()
s224142930
p03776
u255280439
1550811324
Python
Python (3.4.3)
py
Runtime Error
18
3064
398
def main(): N, A, B = [int(_) for _ in sys.stdin.readline().split()] V = sorted([int(_) for _ in sys.stdin.readline().split()], reverse=True) D = collections.defaultdict(lambda: 0) ans = 0 for C in range(A, B+1): if (sum(V[:C]) / C) == (sum(V[:A]) / A): ans += comb(V.count(V[C-1]), V[:C].count(V[C-1])) print(sum(V[:A]) / A) print(ans) main()
s730493669
p03776
u001024152
1550356283
Python
Python (3.4.3)
py
Runtime Error
21
3316
553
# D N,A,B = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) max_mean = sum(v[:A])/A print(max_mean) from collections import Counter from math import factorial def comb(n,r): return factorial(n)//(factorial(r)*factorial(n-r)) v_count = Counter(v) ans = 0 if v[0]==v[A-1]: n = v_count[v[A-1]] for r in range(A, B+1): if r>n: break ans += comb(n, r) else: print(n, r) n = v_count[v[A-1]] select_count = Counter(v[:A]) r = select_count[v[A-1]] ans = comb(n,r) print(ans)
s420482283
p03776
u001024152
1550356086
Python
Python (3.4.3)
py
Runtime Error
22
3316
515
# D N,A,B = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) max_mean = sum(v[:A])/A print(max_mean) from collections import Counter from math import factorial def comb(n,r): return factorial(n)//(factorial(r)*factorial(n-r)) v_count = Counter(v) ans = 0 if v[0]==v[A-1]: n = v_count[v[A-1]] for r in range(A, B+1): ans += comb(n, r) else: n = v_count[v[A-1]] select_count = Counter(v[:A]) r = select_count[v[A-1]] ans = comb(n,r) print(ans)
s922199977
p03776
u089032001
1548820817
Python
Python (3.4.3)
py
Runtime Error
346
22892
565
from collections import Counter from scipy.special import comb def inpl(): return list(map(int, input().split())) N, a, b = inpl() array = inpl() value = Counter(array) array.sort(reverse=True) ans = {} sum_a = 0 kosuu = 0 last = -1 # print("koko") for i, num in enumerate(array): # print(i, num) sum_a += num if last != num: kosuu = 1 last = num else: kosuu += 1 if a <= i+1 <= b: ans[sum_a/(i+1)] = ans.get(sum_a/(i+1), 0) + comb(value[num], kosuu) print("{:.10f}".format(max(ans))) print(int(ans[max(ans)]))
s948087466
p03776
u745087332
1548576257
Python
Python (3.4.3)
py
Runtime Error
22
3316
1060
# coding:utf-8 import sys import math from collections import defaultdict INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def comb(n, r): if n - r < r: return comb(n, n - r) return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n, a, b = LI() V = LI() V.sort() V.reverse() cnt = defaultdict(int) sum_v = 0 for i in range(a): sum_v += V[i] cnt[V[i]] += 1 # 大きい順にa個選ぶ場合,価値の平均値は最大となる print(sum_v / a) # a個選んだ中で一番価値の低いものがいくつ残っているか数える min_v = V[i] min_cnt = cnt[min_v] for i in range(a, n): v = V[i] if v != min_v: break cnt[v] += 1 if cnt[min_v] == min_cnt: print(1) exit() elif len(cnt.keys()) != 1: print(cnt[min_v]) exit() ans = 0 for i in range(b - a + 1): ans += comb(cnt[min_v], min_cnt + i) print(ans)
s768340250
p03776
u745087332
1548572788
Python
Python (3.4.3)
py
Runtime Error
22
3316
1035
# coding:utf-8 import sys import math from collections import defaultdict INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(sys.stdin.readline()) def SI(): return input() def comb(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n, a, b = LI() V = LI() V.sort() V.reverse() cnt = defaultdict(int) sum_v = 0 for i in range(a): sum_v += V[i] cnt[V[i]] += 1 # 大きい順にa個選ぶ場合,価値の平均値は最大となる print(sum_v / a) # a個選んだ中で一番価値の低いものがいくつ残っているか数える min_v = V[i] min_cnt = cnt[min_v] for i in range(a, n): v = V[i] if v != min_v: break cnt[v] += 1 if cnt[min_v] == min_cnt: print(1) exit() elif len(cnt.keys()) != 1: print(comb(cnt[min_v], min_cnt)) exit() ans = 0 for i in range(b - a + 1): ans += comb(cnt[min_v], min_cnt + i) print(ans)
s840120163
p03776
u923279197
1546049530
Python
Python (3.4.3)
py
Runtime Error
18
3064
623
def combination(n, r): # nCrを求める r = min(n - r, r) result = 1 for i in range(n, n - r, -1): result *= i for i in range(1, r + 1): result //= i return result n,a,b = map(int,input().split()) v = list(map(int,input().split())) v.sort(reverse=True) ans1 = v[:a]/a num1 = v[:a].count(v[a-1]) num2 = v[a:n].count(v[a-1]) ans2 = 0 if v[0] == v[a]: for i in range(a,n): if v[i] == v[a-1]: idx = i + 1 for i in range(a,min(b,idx) + 1): ans2 += combination(num1 + num2, i) else: ans2 = combination(num1 + num2,num1) print(ans1) print(ans2)
s371800047
p03776
u026102659
1545876361
Python
Python (3.4.3)
py
Runtime Error
19
3064
424
import math N, A, B = map(int, input().split()) nums = list(map(int, input().split())) arg = 0 num = 0 j = N - A nums.sort() for i in range(A): arg += nums[N - i - 1] arg = arg/A if nums[j] == nums[N-1]: re = nums.count(nums[j]) for i in range(A, B+1): num = num + math.factorial(re) / math.factorial(i) / math.factorial(re-i) else: num = nums.count(nums[j]) print(arg) print(int(num))
s866816202
p03776
u366133198
1542464013
Python
Python (3.4.3)
py
Runtime Error
103
5620
1341
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ https://beta.atcoder.jp/contests/abc057/tasks/abc57_1 """ import sys import math from inspect import currentframe def debug(*args): names = {id(v):k for k,v in currentframe().f_back.f_locals.items()} print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr) u'''calc comibination by pascal's_triangle''' def combination(n, k): return pascal(k + 1, n + 1) pascal_memo = {} def pascal(i, j): if i == 1 or i == j: return 1 else: if (i, j) not in pascal_memo.keys(): pascal_memo[(i, j)] = pascal(i - 1, j - 1) + pascal(i, j - 1) return pascal_memo[(i, j)] N, A, B = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) max_combi = v[:A] max_mean = sum(max_combi) / A print(max_mean) # 一番小さい数字を特定 max_combi_min = min(max_combi) # 一番小さい数字がvにいくつ含まえれるか in_v = v.count(max_combi_min) in_use = max_combi.count(max_combi_min) #in_useからin_vの場合の数 if max_combi[0] != max_combi[-1]: print(int(math.factorial(in_v) / (math.factorial(in_use) * math.factorial(in_v - in_use)))) else: combi_num = 0 for i in range(A, B + 1): combi_num += combination(in_v, i) print(combi_num)
s048138381
p03776
u623601489
1540780762
Python
Python (3.4.3)
py
Runtime Error
17
2940
161
N,A,B=map(int,input().split()) lst=list(map(int,input().split())) lst.sort() a=lst[-A:] print(sum(a)/A) b=lst.count(a[0]) c=lst.count(a[0]) print(b!/(c!*(b-c)!))
s650265482
p03776
u170201762
1540709279
Python
Python (3.4.3)
py
Runtime Error
152
12512
803
def fact(n): if n == 0: return 1 else: return n*fact(n-1) def conb(n,r): return fact(n)//(fact(r)*fact(n-r)) N,A,B = map(int,input().split()) v = list(map(int,input().split())) v.sort() v.reverse() d_all = {} for i in range(N): if v[i] not in d_all: d_all[v[i]] = 0 d_all[v[i]] += 1 import numpy as np avg = np.cumsum(np.array(v)) for i in range(N): avg[i]=int(avg[i])/(i+1) avg = avg[A-1:B] ans = max(avg) print(ans) indices = np.where(avg==ans)[0] ans = 0 for index in indices: d_use = {} use = A + index v_use = v[:use] choose=1 for item in v_use: if item not in d_use: d_use[item] = 0 d_use[item] += 1 for item in d_use: choose *= conv(d_all[item],d_use[item]) ans += choose print(ans)
s816048196
p03776
u368780724
1540646741
Python
Python (3.4.3)
py
Runtime Error
208
15976
436
def inpl(): return [int(i) for i in input().split()] N, A, B = inpl() V = inpl() V = list(reversed(sorted(V))) x1 = N-1 x2 = 0 for i in range(N): if V[i] == V[A]: x1 = min(x1,i) x2 = max(x2,i) print(sum(V[0:A])/A) from scipy.special import comb ans = 0 if x1 == 0: for l in range(min(B-1,x2)-A+2): ans += comb(x2-x1+1,l-x1+1, exact=True) print(ans) else: print(comb(x2-x1+1,A-x1+1, exact=True))
s729170558
p03776
u270681687
1540074298
Python
Python (3.4.3)
py
Runtime Error
21
3316
681
from collections import Counter from itertools import combinations n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) v_cum = [] num = 0 for i in range(n): num += v[i] v_cum.append(num) print(v_cum[a-1]/a) if a == n: print(1) else: if v[a-1] == v[a]: num = v[a-1] cf = Counter(v[:a]) cb = Counter(v[a:]) n_cf = cf[num] n_cb = cb[num] if cf[num] != a: print(combinations(n_cf+n_cb, n_cf)) else: ans = 0 for k in range(a, a+n_cb+1): ans += combinations(a+n_cb, k) print(ans) else: print(1)
s500521986
p03776
u102126195
1538968550
Python
Python (3.4.3)
py
Runtime Error
18
3064
1015
def ABC057D(): N, A, B = map(int, input().split()) v = list(map(int, input().split())) v = sorted(v)[::-1] anslist = [] for i in range(A, B + 1): anslist.append([sum(v[0:i]) / i, i, v[i - 1]]) anslist.sort() anslist = anslist[::-1] ans = anslist[0][0] key = anslist[0][2] long = anslist[0][1] print(ans) for i in range(1, len(anslist)): if anslist[i][0] == anslist[i - 1][0]: ans = anslist[i][0] key = anslist[i][2] long = anslist[i][1] else: break #print(anslist) #print(ans, key, long) cnt = 0 for i in v: if i == key: cnt += 1 c = 0 for i in v[:long]: #print(i) if i == key: c += 1 #print(c, long) ans = 0 if c == long: for i in range(A, min(B + 1, cnt + 1)): ans += cc(cnt, i) else: ans = cc(cnt, c) #print(anslist) #print(cnt, c, long) print(ans) ABC057D()
s741386962
p03776
u631277801
1536577687
Python
Python (3.4.3)
py
Runtime Error
26
3444
1966
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) # nの逆元のリスト def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nの階乗のリスト def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.append(res) return fac # nの階乗の逆元のリスト def fact_inv(n:int, inv:list, mod:int) -> list: facInv = [1,1] for i in range(2,n+1): facInv.append(facInv[i-1]*inv[i] % mod) return facInv # 二項係数 def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int: if not (0<=r and r<=n): return 0 return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod from itertools import accumulate from collections import Counter n,a,b = li() v = li() v.sort(reverse=True) v_cum = list(accumulate(v)) ans_cand = [] # 貪欲に最大値を選ぶ for i in range(a,b+1): ans_cand.append(v_cum[i-1] / i) ans = max(ans_cand) opt_is = [] while ans in ans_cand: opt_is.append(a + ans_cand.index(ans)) ans_cand[ans_cand.index(int(ans))] = 0 cnt_v = Counter(v) # 貪欲最大が何通りできるか考える MOD = 46116646144580591 inv = inv_mod(n, MOD) fac = fact(n, MOD) facInv = fact_inv(n,inv, MOD) pat = 0 for opt_i in opt_is: opt_set = v[:opt_i] cnt_opt = Counter(opt_set) temp = 1 for key_op, val_op in cnt_opt.items(): temp *= nCr(cnt_v[key_op], int(val_op), MOD, fac, facInv) pat += temp print(ans) print(pat)
s323592505
p03776
u631277801
1536577516
Python
Python (3.4.3)
py
Runtime Error
22
3444
1957
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) # nの逆元のリスト def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nの階乗のリスト def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.append(res) return fac # nの階乗の逆元のリスト def fact_inv(n:int, inv:list, mod:int) -> list: facInv = [1,1] for i in range(2,n+1): facInv.append(facInv[i-1]*inv[i] % mod) return facInv # 二項係数 def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int: if not (0<=r and r<=n): return 0 return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod from itertools import accumulate from collections import Counter n,a,b = li() v = li() v.sort(reverse=True) v_cum = list(accumulate(v)) ans_cand = [] # 貪欲に最大値を選ぶ for i in range(a,b+1): ans_cand.append(v_cum[i-1] / i) ans = max(ans_cand) opt_is = [] while ans in ans_cand: opt_is.append(a + ans_cand.index(ans)) ans_cand[ans_cand.index(int(ans))] = 0 cnt_v = Counter(v) # 貪欲最大が何通りできるか考える MOD = 10**18+1 inv = inv_mod(n, MOD) fac = fact(n, MOD) facInv = fact_inv(n,inv, MOD) pat = 0 for opt_i in opt_is: opt_set = v[:opt_i] cnt_opt = Counter(opt_set) temp = 1 for key_op, val_op in cnt_opt.items(): temp *= nCr(cnt_v[key_op], int(val_op), MOD, fac, facInv) pat += temp print(ans) print(pat)
s140982237
p03776
u550574002
1536229670
Python
Python (3.4.3)
py
Runtime Error
17
3064
309
n,a,b = map(int,input().split()) vs = sorted([int(v) for v in input().split()],reverse=True) print(sum(vs[:a])/a) binom = [1] for k in range(vs.count(vs[a-1])): binom = [x+y for (x, y) in zip(binom+[0],[0]+binom)] if vs[a-1] == vs[0]: print(sum(binom[a:b+1])) else: print(binom[vs.index(vs[a-1])])
s311805688
p03776
u255280439
1535765257
Python
Python (3.4.3)
py
Runtime Error
191
14884
3161
import sys import math import collections import itertools import array import inspect from scipy.special import comb # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = { id(v): k for k, v in inspect.currentframe().f_back.f_locals.items() } print(', '.join( names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans class Combination: def __init__(self, n, mod=10**100): g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range(2, n + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) self.MOD = mod self.N = n self.g1 = g1 self.g2 = g2 self.inverse = inverse def __call__(self, n, r): if (r < 0 or r > n): return 0 r = min(r, n - r) return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD # -------------------------------------------- dp = None def main(): N, A, B = li_input() V = li_input() V.sort(reverse=True) maxavg = sum(V[:A]) / A V_ = V[:A] if V_[0] == V_[-1]: n = V.count(V_[0]) ans = 0 for r in range(A, min(n + 1, B + 1)): ans += comb(n, r) print(maxavg) print(int(ans)) else: n = V.count(V_[-1]) r = V_.count(V_[-1]) ans = comb(n, r) print(maxavg) print(int(ans)) main()
s545772974
p03776
u445863230
1530230310
Python
Python (3.4.3)
py
Runtime Error
18
3064
631
poo=input().split() shoop=[1] lop=[] for i in range(int(poo[0])): lop.append(int(input())) shoop.append(shoop[i]*(i+1)) jop=lop.copy() j=int(poo[1]) staph=int(poo[2]) joop=0 z=0 zop=jop.count(max(jop)) while z<j: joop+=max(lop) lop.remove(max(lop)) z+=1 print(joop/j) jum=1 shazam=0 while j>=zop: shazam+=zop j=j-zop for i in range(zop): jop.remove(max(jop)) zop=jop.count(max(jop)) if zop>j and j>0: jum=0 som=int(poo[1]) while min(staph,shazam+zop)>=som: while j<=som: jum+=shoop[zop]//(shoop[j]*shoop[zop-j]) j+=1 som+=1 print(jum)
s467836587
p03776
u445863230
1530226160
Python
Python (3.4.3)
py
Runtime Error
18
3064
636
poo=input().split() lop=[] for i in range(int(poo[0])): lop.append(int(input())) j=int(poo[1]) joop=0 z=0 while z<j: joop+=max(jop) jop.remove(max(jop)) z+=1 print(loo/j) sum=0 zop=lop.count(max(lop)) while j>zop: prod=1 sop=0 while sop<zop: prod=prod*(zop-sop) sop+=1 sum+=prod j=j-zop for i in range(zop): lop.remove(max(lop)) zop=lop.count(max(lop)) if lop.count(max(lop))>=j and j>0: while joop<j: joop+=1 sop=0 prod=1 while sop<j: prod=prod*(lop.count(max(lop))-sop) sop+=1 sum+=prod print(sum)
s209162557
p03776
u445863230
1530225782
Python
Python (3.4.3)
py
Runtime Error
19
3064
635
poo=input().split() lop=[] for i in range(int(poo[0])): lop.append(int(input())) j=int(poo[1]) joop=0 z=0 while z<j: loo+=max(jop) jop.remove(max(jop)) z+=1 print(loo/j) sum=0 zop=lop.count(max(lop)) while j>zop: prod=1 sop=0 while sop<zop: prod=prod*(zop-sop) sop+=1 sum+=prod j=j-zop for i in range(zop): lop.remove(max(lop)) zop=lop.count(max(lop)) if lop.count(max(lop))>=j and j>0: while joop<j: joop+=1 sop=0 prod=1 while sop<j: prod=prod*(lop.count(max(lop))-sop) sop+=1 sum+=prod print(sum)
s998083761
p03776
u503283842
1530164470
Python
Python (3.4.3)
py
Runtime Error
17
3064
652
b=int(x[2]) v=input().split() x=0 while x<n: v[x]=int(v[x]) x+=1 v.sort() ave=0 for i in range(a): ave+=v[-i-1] print(ave/a) up=1 down=1 ans=0 x=v[-a:].count(v[-a]) y=v.count(v[-a]) if v[-1]!=v[-a]: for i in range(1,y+1): up*=i for i in range(1,x): down*=i for i in range(1, y-x+1): down*=i print(up//down) else: ii=a while ii<=b and v[-ii]==v[-1]: up=1 down=1 for i in range(1,y+1): up*=i for i in range(1,ii+1): down*=i for i in range(1, y-ii+1): down*=i ans+=(up//down) ii+=1 print(ans)
s760455443
p03776
u503283842
1530163573
Python
Python (3.4.3)
py
Runtime Error
18
3064
694
x=input().split() n=int(x[0]) a=int(x[1]) b=int(x[2]) v=input().split() x=0 while x<n: v[x]=int(v[x]) x+=1 v.sort() ave=0 for i in range(a): ave+=v[-i-1] print(ave/a) up=1 down=1 ans=0 x=v[-a:].count(v[-a]) y=v.count(v[-a]) if v[-1]!=v[-a]: for i in range(1,y+1): up*=i for i in range(1,x): down*=i for i in range(1, y-x+1): down*=i print(up//down) else: ii=a while v[-ii]==v[-1] and ii<=b: up=1 down=1 for i in range(1,y+1): up*=i for i in range(1,ii+1): down*=i for i in range(1, y-ii+1): down*=i ans+=(up//down) ii+=1 print(ans)
s354895396
p03776
u503283842
1530163203
Python
Python (3.4.3)
py
Runtime Error
18
3064
695
x=input().split() n=int(x[0]) a=int(x[1]) b=int(x[2]) v=input().split() x=0 while x<n: v[x]=int(v[x]) x+=1 v.sort() ave=0 for i in range(a): ave+=v[-i-1] print(ave/a) up=1 down=1 ans=0 x=v[-a:].count(v[-a]) y=v.count(v[-a]) if v[-1]!=v[-a]: for i in range(2,y+1): up*=i for i in range(2,x): down*=i for i in range(2, y-x+1): down*=i print(up//down) else: ii=a while v[-ii]==v[-1] and ii<=b: up=1 down=1 for i in range(1,y+1): up*=i for i in range(1,ii+1): down*=i for i in range(1, y-ii+1): down*=i ans+=(up//down) ii+=1 print(ans)
s347621787
p03776
u503283842
1530162734
Python
Python (3.4.3)
py
Runtime Error
17
3188
642
n=int(x[0]) a=int(x[1]) b=int(x[2]) v=input().split() x=0 while x<n: v[x]=int(v[x]) x+=1 v.sort() ave=0 for i in range(a): ave+=v[-i-1] print(ave/a) up=1 down=1 ans=0 x=v[-a:].count(v[-a]) y=v.count(v[-a]) if v[-1]!=v[-a]: for i in range(2,y+1): up*=i for i in range(2,x): down*=i for i in range(2, y-x+1): down*=i print(up//down) else: i=a while v[-i]==v[-1] and i!=b: for i in range(2,y+1): up*=i for i in range(2,i+1): down*=i for i in range(2, y-i+1): down*=i ans+=(up//down) i+=1 print(ans)
s753349485
p03776
u064408584
1529292695
Python
Python (3.4.3)
py
Runtime Error
23
3444
436
import math from collections import Counter def f(a,b): return math.factorial(a) // (math.factorial(a - b) * math.factorial(b)) n,a,b=map(int, input().split()) v=list(map(int, input().split())) v.sort(reverse=True) c=Counter(v) count=0 if a==1 or v[0]==v[a-1]: for i in range(a,min(b,c[v[0]])+1): count+=f(min(b,c[v[0]]),i) print(v[0]) print(count) else: print(sum(v[:a])/a) print(f(c[v[a]],a-c[v[0]]))
s941984636
p03776
u278479217
1527137776
Python
Python (3.4.3)
py
Runtime Error
18
3064
768
# from math import inf inf = 10**50 N, M = map(int, input().split()) edges = [] for j in range(M): edges.append(list(map(int, input().split()))) d = [0] + ([-inf]*(N-1)) pred = [None] * N for i in range(N-1): for j in range(M): u = edges[j][0]-1 v = edges[j][1]-1 w = edges[j][2] if (d[v] < d[u] + w) and (d[u] != -inf): d[v] = d[u] + w pred[v] = u positive_loop = False for i in range(N): for j in range(M): u = edges[j][0]-1 v = edges[j][1]-1 w = edges[j][2] if (v == N-1) and (d[u] + w > d[v]) and (d[u] != -inf): positive_loop = True break if positive_loop: break if positive_loop: print("inf") else: print(d[N-1])
s824986801
p03776
u218843509
1525586847
Python
Python (3.4.3)
py
Runtime Error
17
3064
496
from math import factorial n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) n1 = v.count(v[a - 1]) n2 = v[:a].count(v[:a][a - 1]) print(sum(v[:a]) / a) if len(set(v[:a])) != 1: if n1 == n2: print(1) else: print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2)))) else: ans = 0 if n1 == 1: print(1) else: for i in range(a, min(n1, b + 1)): if ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i))) print(int(ans))
s553884636
p03776
u218843509
1525586721
Python
Python (3.4.3)
py
Runtime Error
17
3064
480
from math import factorial n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) n1 = v.count(v[a - 1]) n2 = v[:a].count(v[:a][a - 1]) print(sum(v[:a]) / a) if len(set(v[:a])) != 1: if n1 == n2: print(1) else: print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2)))) else: ans = 0 if n1 == 1: print(1) else: for i in range(a, b + 1): ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i))) print(int(ans))
s741525559
p03776
u218843509
1525586540
Python
Python (3.4.3)
py
Runtime Error
18
3064
413
from math import factorial n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) n1 = v.count(v[a - 1]) n2 = v[:a].count(v[:a][a - 1]) print(sum(v[:a]) / a) if len(set(v[:a])) != 1: print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2)))) else: ans = 0 for i in range(a, b + 1): ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i))) print(int(ans))
s856396856
p03776
u218843509
1525586447
Python
Python (3.4.3)
py
Runtime Error
36
5176
418
from fractions import factorial n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) n1 = v.count(v[a - 1]) n2 = v[:a].count(v[:a][a - 1]) print(sum(v[:a]) / a) if len(set(v[:a])) != 1: print(int(factorial(n1) / (factorial(n2) * factorial(n1 - n2)))) else: ans = 0 for i in range(a, b + 1): ans += int(factorial(n1) / (factorial(i) * factorial(n1 - i))) print(int(ans))
s369035825
p03776
u218843509
1525586340
Python
Python (3.4.3)
py
Runtime Error
17
3064
423
import math n, a, b = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) n1 = v.count(v[a - 1]) n2 = v[:a].count(v[:a][a - 1]) print(sum(v[:a]) / a) if len(set(v[:a])) != 1: print(int(math.factorial(n1) / (math.factorial(n2) * math.factorial(n1 - n2)))) else: ans = 0 for i in range(a, b + 1): ans += int(math.factorial(n1) / (math.factorial(i) * math.factorial(n1 - i))) print(ans)
s018973434
p03776
u429843511
1522371359
Python
Python (3.4.3)
py
Runtime Error
195
15332
650
import numpy as np import scipy.special as ss N, A, B = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) v = np.array(v) ##print(v) ansarray = v[0:A] ##print(ansarray) ave = np.mean(ansarray) print(float(ave)) mi = min(ansarray) ma = max(ansarray) biggerarray = v[v>mi] m = len(biggerarray) numminarray = v[v==mi] a = len(numminarray) ##print(nummin) ##print(num_kouho) ans = 0 if ma == mi: if m+a <= B: for i in range(A-m,a+1): ans+=ss.comb(a,i) else: for i in range(A-m,B-m+1): ans+=ss.comb(a,i) else: ans = a #print('a=',a) #print('m=',m) print(int(ans))
s458256840
p03776
u429843511
1522370770
Python
Python (3.4.3)
py
Runtime Error
307
20776
637
import numpy as np import scipy.special as ss N, A, B = map(int, input().split()) v = list(map(int, input().split())) v.sort(reverse=True) v = np.array(v) ##print(v) ansarray = v[0:A] ##print(ansarray) ave = np.mean(ansarray) print(ave) mi = min(ansarray) ma = max(ansarray) biggerarray = v[v>mi] m = len(biggerarray) numminarray = v[v==mi] a = len(numminarray) ##print(nummin) ##print(num_kouho) ans = 0 if ma == mi: if m+a <= B: for i in range(A-m,a+1): ans+=ss.comb(a,i) else: for i in range(A-m,B-m+1): ans+=ss.comb(a,i) else: ans = a #print('a=',a) #print('m=',m) print(int(ans))
s064507741
p03776
u761320129
1505955485
Python
Python (3.4.3)
py
Runtime Error
23
3316
578
from collections import Counter N,A,B = map(int,input().split()) src = list(map(int,input().split())) src.sort(reverse=True) ave = sum(src[:A]) / A print(ave) counter = Counter(src) cnt = counter[src[0]] ncr = [[1]] for n in range(1,N+1): ncr.append([1]) for r in range(1,n): ncr[n].append(ncr[n-1][r-1] + ncr[n-1][r]) ncr[n].append(1) if cnt < A: last = src[A-1] n = counter[last] r = src[:A].count(last) print(ncr[n][r]) elif cnt == A: print(1) else: ans = 0 for r in range(A,B+1): ans += ncr[cnt][r] print(ans)
s195182365
p03776
u761320129
1505955143
Python
Python (3.4.3)
py
Runtime Error
24
3444
550
from collections import Counter N,A,B = map(int,input().split()) src = list(map(int,input().split())) src.sort(reverse=True) ave = sum(src[:A]) / A print(ave) counter = Counter(src) cnt = counter[src[0]] ncr = [[1]] for n in range(1,N+1): ncr.append([1]) for r in range(1,n): ncr[n].append(ncr[n-1][r-1] + ncr[n-1][r]) ncr[n].append(1) if cnt < A: last = src[A-1] n = counter[last] r = src[:A].count(last) print(ncr[n][r]) else: ans = 0 for r in range(A,B+1): ans += ncr[cnt][r] print(ans)
s465792469
p03776
u343437894
1499483442
Python
Python (3.4.3)
py
Runtime Error
18
3188
608
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) revpos=revv.index(v[-a]); num=v.count(v[-a]); ans=0 if v[-1] == v[-a] == v[-a-1]: for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans); else: print(ncr(num,a-revpos));
s231820336
p03776
u343437894
1499483388
Python
Python (3.4.3)
py
Runtime Error
18
3064
563
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) ans=0 if v[-1] == v[-a] == v[-a-1]: for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans); else: print(ncr(num,a-revpos));
s929948426
p03776
u343437894
1499483258
Python
Python (3.4.3)
py
Runtime Error
18
3064
547
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) ans=0 if v[-1] == v[-a] == v[-a-1]: for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans); else: print(1);
s440669990
p03776
u343437894
1499482164
Python
Python (3.4.3)
py
Runtime Error
17
3188
580
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) revpos=revv.index(v[-a]); num=v.count(v[-a]); ans=0; if a == revpos: print(1); else: for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans);
s759730079
p03776
u343437894
1499482121
Python
Python (3.4.3)
py
Runtime Error
17
3064
579
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) revpos=revv.index(v[-a]); num=v.count(v[-a]); ans=0; if a == revpos: print 1; else: for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans);
s733400438
p03776
u343437894
1499481864
Python
Python (3.4.3)
py
Runtime Error
17
3064
532
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) revpos=revv.index(v[-a]); num=v.count(v[-a]); ans=0; for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans);
s869665077
p03776
u343437894
1499481789
Python
Python (3.4.3)
py
Runtime Error
19
3064
532
from math import factorial n, a, b = map(int, input().split(" ")); v = list(map(int, input().split(" "))) def product(iterable): prod = 1 for n in iterable: prod *= n return prod def npr(n, r): return product(range(n - r + 1, n + 1)) def ncr(n, r): if r > n // 2: r = n - r return npr(n, r) // factorial(r) v.sort(); revv=list(reversed(v)) print(sum(v[-a:])/a) revpos=revv.index(v[-a]); num=v.count(v[-a]); ans=0; for i in range(a-revpos, b-revpos+1): ans+=ncr(num, i); print(ans);
s368307092
p03776
u667084803
1494453469
Python
Python (3.4.3)
py
Runtime Error
17
3064
611
import math N,A,B=map(int, input().split()) v=list(map(int, input().split())) v.sort() v.reverse() w=0 for i in range (0,A): w+=v[i] ave=w/A print(ave) min=v[A] C=v[0:A].count(min)#最低個数 D=v[0:A].count(min)+B-A#要素が増えても平均が落ちない場合の最大個数 if v[0]!=v[A]:#要素が増えたら平均が落ちる場合 D=A for k in range (0,A): if v[k]>v[A]: D-=1#最大個数はB-(v[A]より大きいものの個数) p=v.count(min)#最小の人たちの個数 q=0 for k in range (C,D+1): q+=math.factorial(p)/(math.factorial(p-k)*math.factorial(k)) print(int(q))
s542536192
p03776
u975024434
1493259319
Python
Python (3.4.3)
py
Runtime Error
21
3316
480
def combi(n, r): if r == 0 or n == r: return 1 return combi(n-1, r-1) + combi(n-1, r) n, a, b = map(int, input().split()) items = sorted(map(int, input().split()), reverse=True) max_ave_list = imtes[:a] print(sum(max_ave_list)/len(max_ave_list)) m = max_ave_list.count(max_ave_list[-1]) l = items.count(max_ave_list[-1]) if l == m: print(1) elif max_ave_list[0] != max_ave_list[-1]: print(combi(l, m)) else: print(sum(combi(l, k) for k in range(m, min(b, l) + 1)))
s237078110
p03776
u975024434
1493258095
Python
Python (3.4.3)
py
Runtime Error
18
3192
1317
def f1(i): if(i == 1): return 1 return i*f1(i-1) def f2(a, b): print(a, b) return f1(a)/(f1(b)*f1(a-b)) a = [int(i) for i in input().split()] v = [int(i) for i in input().split()] sorted_v = sorted(v) b = [] c = {} sum = 0 count = 0 for i in range(a[1]): b.append(sorted_v[a[0] - i -1]) if(not sorted_v[a[0] - i -1] in c): c[sorted_v[a[0] - i -1]] = 1 else: c[sorted_v[a[0] - i -1]] += 1 sum += sorted_v[a[0] - i -1] count += 1 pattern = 1 memory = count max = max(b) if(max == sorted_v[a[0] - memory -1] and count == c[sorted_v[a[0] - memory -1]] ): tmp = c[max] while(max == sorted_v[a[0] - memory -1]): c[max] += 1 memory += 1 if(a[0] - memory -1 == -1): break if(c[max] > a[2]): pattern = 0 pattern = f2(c[max], a[2]) else: pattern = 1 for i in range(a[1], min(c[max], a[2])): pattern += f2(c[max], i) else: if(sorted_v[a[0] - memory -1] == b[-1]): e = c[sorted_v[a[0] - memory -1]] while(sorted_v[a[0] - memory -1] == b[-1]): c[sorted_v[a[0] - memory -1]] += 1 memory += 1 if(a[0] - memory -1 == -1): memory -= 1 break pattern = f2(c[sorted_v[a[0] - memory -1]], e) else: pattern = 1 print("{0:.7f}".format(sum/count)) print(pattern)
s499327548
p03776
u103099441
1492904213
Python
Python (3.4.3)
py
Runtime Error
17
3064
279
n, a, b = map(int, input().split()) li = [] for i in range(n): li.append(int(input())) li = sorted(li) m = sum(li[-a: -1]) print(m) c = 0 p = 1 for i in range(b - a): if li[-a - i] == li[-a]: c += 1 for i in li[-a: -1]: if i == li[-a]: p += c print(p)
s569690499
p03776
u340781749
1492704125
Python
Python (3.4.3)
py
Runtime Error
59
3980
677
def memoize(f): cache = {} def func(*args): if args not in cache: cache[args] = f(*args) return cache[args] return func @memoize def combi(n, r): if r == 0 or n == r: return 1 return combi(n - 1, r - 1) + combi(n - 1, r) n, a, b = map(int, input().split()) items = sorted(map(int, input().split()), reverse=True) max_ave_list = items[:a] print(sum(max_ave_list) / len(max_ave_list)) m = max_ave_list.count(max_ave_list[-1]) l = items.count(max_ave_list[-1]) if l == m: print(1) elif max_ave_list[0] != max_ave_list[-1]: print(combi(l, m)) else: print(sum(combi(l, k) for k in range(m, max(b, l) + 1)))
s297136377
p03776
u104282757
1491688002
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38512
747
import numpy as np import itertools N, A, B = list(map(int, input().split())) V = np.array(list(map(int, input().split()))) V.sort() V[:] = V[::-1] def nCr(n, r): return(len(list(itertools.combinations(np.arange(n), p)))) d = V[A-1] # unless all equal, we only need A if d == V.max(): # count how many d d_eq_cnt = np.count_nonzero(V == d) res = nCr(d_eq_cnt, A) res_sum = res for k in range(1, min(B, d_eq_cnt) + 1 - A): res = res * (d_eq_cnt - (A+k-1)) // (A+k) res_sum += res print(V[:A].mean()) print(res_sum) else: # count how many d d_eq_cnt = np.count_nonzero(V == d) d_lq_cnt = np.count_nonzero(V > d) print(V[:A].mean()) print(nCr(d_eq_cnt, A - d_lq_cnt))
s401656225
p03776
u306773664
1491213286
Python
Python (3.4.3)
py
Runtime Error
18
3064
539
#! coding: UTF-8 data1 = list(map(int,input().split(" "))) N = data1[0] A = data1[1] B = data1[2] data2 = list(map(int,input().split(" "))) data2.sort(reverse=True) max_avr = sum(data2[:A]) / A a_num = data2.count(data2[A-1]) a_pos = data2[:A].count(data2[A-1]) #確率統計nCr import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) cnt = 0 if a_pos == A: while a_pos <= B: cnt += nCr(a_num,a_pos) a_pos += 1 else: cnt = nCr(a_num,a_pos) print("{0:.10f}".format(max_avr)) print(int(cnt))
s318847071
p03776
u306773664
1491212268
Python
Python (3.4.3)
py
Runtime Error
17
3064
538
#! coding: UTF-8 data1 = list(map(int,input().split(" "))) N = data1[0] A = data1[1] B = data1[2] data2 = list(map(int,input().split(" "))) data2.sort(reverse=True) max_avr = sum(data2[:A]) / A a_num = data2.count(data2[A-1]) a_pos = data2[:A].count(data2[A-1]) #確率統計nCr import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) cnt = 0 if a_pos == A: while a_pos <= B: cnt += nCr(a_num,a_pos) a_pos += 1 else: cnt = nCr(a_num,a_pos) print("{0:.6f}".format(max_avr)) print(int(cnt))
s431488532
p03776
u306773664
1491211997
Python
Python (3.4.3)
py
Runtime Error
17
3064
576
#! coding: UTF-8 data1 = list(map(int,input().split(" "))) N = data1[0] A = data1[1] B = data1[2] data2 = list(map(int,input().split(" "))) data2.sort(reverse=True) max_avr = sum(data2[:A]) / A a_num = 0 a_pos = 0 for i in range(N): if data2[i] == data2[A-1]: a_num += 1 if i < A: a_pos += 1 #確率統計nCr import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) cnt = 0 if a_pos == A: while a_pos <= B: cnt += nCr(a_num,a_pos) a_pos += 1 else: cnt = nCr(a_num,a_pos) print("{0:.6f}".format(max_avr)) print(int(cnt))
s110809690
p03776
u306773664
1491210680
Python
Python (3.4.3)
py
Runtime Error
17
3064
586
#! coding: UTF-8 data1 = list(map(int,input().split(" "))) N = data1[0] A = data1[1] B = data1[2] data2 = list(map(int,input().split(" "))) data2.sort(reverse=True) max_avr = sum(data2[:A]) max_avr /= A a_num = 0 a_pos = 0 for i in range(N): if data2[i] == data2[A-1]: a_num += 1 if i < A: a_pos += 1 #確率統計nCr import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) cnt = 0 if a_pos == A: while a_pos <= B: cnt += nCr(a_num,a_pos) a_pos += 1 else: cnt += nCr(a_num,a_pos) print("{0:.6f}".format(max_avr)) print(int(cnt))
s073146522
p03776
u306773664
1491210388
Python
Python (3.4.3)
py
Runtime Error
18
3064
613
#! coding: UTF-8 data1 = list(map(int,input().split(" "))) N = data1[0] A = data1[1] B = data1[2] data2 = list(map(int,input().split(" "))) data2.sort(reverse=True) max_avr = 0 for i in range(A): max_avr += data2[i] max_avr /= A a_num = 0 a_pos = 0 for i in range(N): if data2[i] == data2[A-1]: a_num += 1 if i < A: a_pos += 1 #確率統計nCr import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) cnt = 0 if a_pos == A: while a_pos <= B: cnt += nCr(a_num,a_pos) a_pos += 1 else: cnt += nCr(a_num,a_pos) print("{0:.6f}".format(max_avr)) print(int(cnt))
s155223875
p03776
u076936237
1491006657
Python
Python (3.4.3)
py
Runtime Error
26
6816
24053
class Comb: def __init__(self, N): super(Comb, self).__init__() self.dic = {(7, 3): 35, (31, 6): 736281, (46, 42): 163185, (42, 33): 445891810, (41, 13): 17620076360, (16, 9): 11440, (40, 22): 113380261800, (19, 4): 3876, (43, 3): 12341, (41, 23): 202112640600, (22, 19): 1540, (46, 12): 38910617655, (20, 7): 77520, (44, 4): 135751, (42, 20): 513791607420, (47, 9): 1362649145, (21, 6): 54264, (36, 34): 630, (43, 25): 608359048206, (8, 5): 56, (32, 2): 496, (37, 35): 666, (35, 15): 3247943160, (33, 3): 5456, (48, 37): 22595200368, (36, 8): 30260340, (10, 7): 120, (34, 8): 18156204, (49, 32): 6499270398159, (42, 10): 1471442973, (37, 13): 3562467300, (35, 21): 2319959400, (50, 39): 37353738800, (24, 14): 1961256, (14, 1): 14, (38, 2): 703, (36, 22): 3796297200, (25, 15): 3268760, (15, 4): 1365, (39, 11): 1676056044, (37, 23): 6107086800, (26, 12): 9657700, (50, 1): 50, (48, 17): 4244421484512, (29, 17): 51895935, (3, 2): 3, (27, 1): 27, (49, 28): 39049918716424, (30, 14): 145422675, (28, 10): 13123110, (50, 27): 108043253365600, (31, 15): 300540195, (46, 45): 46, (29, 11): 34597290, (40, 29): 2311801440, (30, 16): 145422675, (19, 13): 27132, (17, 13): 2380, (41, 24): 151584480450, (31, 21): 44352165, (46, 23): 8233430727600, (20, 14): 38760, (44, 3): 13244, (18, 10): 43758, (42, 31): 4280561376, (23, 19): 8855, (40, 35): 658008, (21, 15): 54264, (45, 2): 990, (43, 30): 36576848168, (43, 39): 123410, (32, 25): 3365856, (22, 12): 646646, (44, 25): 1408831480056, (33, 4): 40920, (23, 9): 817190, (38, 35): 8436, (45, 28): 1103068603890, (34, 3): 5984, (35, 26): 70607460, (24, 21): 2024, (14, 8): 3003, (38, 5): 501942, (12, 8): 495, (36, 29): 8347680, (25, 16): 2042975, (15, 13): 105, (41, 36): 749398, (37, 16): 12875774670, (40, 14): 23206929840, (26, 23): 2600, (48, 8): 377348994, (38, 31): 12620256, (27, 6): 296010, (49, 21): 39049918716424, (39, 30): 211915132, (28, 1): 28, (45, 9): 886163135, (5, 1): 5, (29, 4): 23751, (16, 7): 11440, (40, 4): 91390, (30, 27): 4060, (19, 18): 19, (17, 6): 12376, (41, 1): 41, (31, 18): 206253075, (46, 30): 991493848554, (42, 35): 26978328, (18, 5): 8568, (41, 15): 63432274896, (47, 31): 1503232609098, (21, 8): 203490, (34, 32): 561, (32, 16): 601080390, (22, 7): 170544, (44, 16): 416714805914, (33, 29): 40920, (23, 6): 100947, (45, 37): 215553195, (45, 21): 3773655750150, (10, 9): 10, (34, 26): 18156204, (39, 35): 82251, (11, 4): 330, (35, 3): 6545, (44, 34): 2481256778, (48, 41): 73629072, (12, 7): 792, (36, 4): 58905, (43, 42): 43, (15, 10): 3003, (13, 6): 1716, (37, 25): 1852482996, (24, 2): 276, (48, 15): 1093260079344, (38, 22): 22239974430, (25, 3): 2300, (49, 14): 675248872536, (39, 23): 37711260990, (28, 24): 20475, (50, 13): 354860518600, (45, 34): 10150595910, (49, 11): 29135916264, (6, 1): 6, (30, 2): 435, (45, 32): 73006209045, (7, 4): 35, (31, 27): 31465, (46, 33): 101766230790, (42, 1): 42, (40, 17): 88732378800, (21, 17): 5985, (19, 1): 19, (43, 12): 15338678264, (32, 23): 28048800, (46, 11): 13340783196, (35, 34): 35, (33, 22): 193536720, (47, 18): 4568648125690, (47, 2): 1081, (45, 14): 166871334960, (34, 21): 927983760, (32, 13): 347373600, (35, 8): 23535820, (33, 8): 13884156, (48, 32): 2254848913647, (36, 3): 7140, (34, 15): 1855967520, (49, 45): 211876, (37, 2): 666, (26, 25): 26, (50, 42): 536878650, (24, 9): 1307504, (48, 6): 12271512, (38, 9): 163011640, (27, 20): 888030, (25, 4): 12650, (49, 7): 85900584, (39, 12): 3910797436, (41, 38): 10660, (28, 23): 98280, (26, 3): 2600, (50, 4): 230300, (48, 28): 16735679449896, (29, 22): 1560780, (27, 10): 8436285, (49, 25): 63205303218876, (30, 5): 142506, (28, 13): 37442160, (45, 11): 10150595910, (46, 40): 9366819, (42, 8): 118030185, (16, 11): 4368, (40, 24): 62852101650, (44, 39): 1086008, (19, 6): 27132, (43, 5): 962598, (17, 10): 19448, (41, 21): 269128937220, (22, 17): 26334, (46, 18): 2818953098830, (20, 1): 20, (42, 37): 850668, (18, 17): 18, (42, 18): 353697121050, (23, 20): 1771, (47, 11): 17417133617, (21, 4): 5985, (45, 7): 45379620, (43, 27): 265182149218, (8, 7): 8, (32, 4): 35960, (22, 11): 705432, (37, 33): 66045, (44, 28): 416714805914, (9, 6): 84, (33, 1): 33, (48, 39): 1677106640, (47, 40): 62891499, (36, 10): 254186856, (10, 5): 252, (34, 6): 1344904, (49, 38): 29135916264, (37, 11): 854992152, (11, 8): 165, (35, 23): 834451800, (50, 37): 354860518600, (24, 16): 735471, (14, 7): 3432, (44, 33): 7669339132, (36, 16): 7307872110, (25, 13): 5200300, (15, 6): 5005, (39, 5): 575757, (37, 21): 12875774670, (26, 10): 5311735, (48, 19): 11541847896480, (38, 26): 2707475148, (27, 3): 2925, (47, 39): 314457495, (49, 18): 11554258485616, (30, 12): 86493225, (28, 4): 20475, (50, 25): 126410606437752, (31, 9): 20160075, (29, 9): 10015005, (16, 2): 120, (40, 31): 273438880, (30, 22): 5852925, (19, 15): 3876, (17, 3): 680, (41, 30): 3159461968, (31, 23): 7888725, (46, 21): 6943526580276, (20, 8): 125970, (18, 8): 43758, (33, 32): 33, (40, 37): 9880, (21, 13): 203490, (50, 12): 121399651100, (43, 16): 265182149218, (32, 27): 201376, (22, 2): 231, (43, 32): 5752004349, (44, 27): 686353797976, (33, 26): 4272048, (23, 11): 1352078, (38, 33): 501942, (45, 26): 2438362177020, (34, 1): 34, (39, 36): 9139, (11, 1): 11, (35, 28): 6724520, (24, 23): 24, (12, 10): 66, (36, 31): 376992, (44, 8): 177232627, (25, 22): 2300, (39, 2): 741, (13, 11): 78, (37, 30): 10295472, (26, 21): 65780, (48, 10): 6540715896, (38, 29): 163011640, (42, 40): 861, (27, 24): 2925, (47, 34): 140676848445, (39, 24): 25140840660, (41, 32): 350343565, (28, 3): 3276, (50, 16): 4923689695575, (29, 2): 406, (47, 33): 341643774795, (40, 6): 3838380, (30, 25): 142506, (17, 4): 2380, (41, 7): 22481940, (31, 28): 4495, (46, 28): 2818953098830, (18, 3): 816, (42, 4): 111930, (47, 25): 14833897694226, (47, 21): 12551759587422, (43, 9): 563921995, (32, 18): 471435600, (22, 5): 26334, (46, 6): 9366819, (42, 39): 11480, (33, 19): 818809200, (47, 7): 62891499, (47, 42): 1533939, (45, 19): 2438362177020, (34, 24): 131128140, (32, 8): 10518300, (11, 6): 462, (35, 5): 324632, (48, 43): 1712304, (12, 1): 12, (36, 6): 1947792, (49, 42): 85900584, (13, 4): 715, (37, 7): 10295472, (48, 44): 194580, (24, 4): 10626, (48, 1): 48, (38, 20): 33578000610, (27, 17): 8436285, (25, 1): 25, (49, 12): 92263734836, (39, 17): 51021117810, (28, 26): 378, (26, 6): 230230, (50, 11): 37353738800, (29, 27): 406, (47, 37): 5178066751, (40, 13): 12033222880, (7, 6): 7, (31, 5): 169911, (46, 39): 53524680, (47, 20): 9762479679106, (42, 15): 98672427616, (40, 19): 131282408400, (45, 39): 8145060, (19, 3): 969, (43, 14): 78378960360, (41, 18): 202112640600, (46, 9): 1101716330, (20, 4): 4845, (44, 9): 708930508, (33, 20): 573166440, (47, 12): 52251400851, (45, 12): 28760021745, (34, 19): 1855967520, (8, 2): 28, (32, 15): 565722720, (35, 10): 183579396, (9, 3): 84, (33, 14): 818809200, (47, 22): 14833897694226, (36, 13): 2310789600, (34, 13): 927983760, (49, 35): 675248872536, (35, 16): 4059928950, (45, 35): 3190187286, (24, 11): 2496144, (14, 2): 91, (38, 15): 15471286560, (27, 22): 80730, (25, 10): 3268760, (49, 5): 1906884, (39, 14): 15084504396, (28, 17): 21474180, (26, 1): 26, (50, 2): 1225, (48, 30): 7309837001104, (29, 20): 10015005, (3, 1): 3, (27, 12): 17383860, (49, 31): 11554258485616, (30, 11): 54627300, (41, 34): 22481940, (28, 15): 37442160, (40, 8): 76904685, (50, 28): 88749815264600, (31, 2): 465, (29, 14): 77558760, (16, 13): 560, (40, 26): 23206929840, (19, 8): 75582, (43, 7): 32224114, (17, 8): 24310, (41, 27): 35240152720, (46, 16): 991493848554, (20, 3): 1140, (18, 15): 816, (42, 16): 166509721602, (23, 22): 23, (40, 32): 76904685, (21, 2): 210, (45, 5): 1221759, (43, 29): 78378960360, (32, 6): 906192, (22, 9): 497420, (44, 30): 114955808528, (9, 4): 126, (33, 7): 4272048, (23, 12): 1352078, (45, 31): 166871334960, (10, 3): 120, (34, 4): 46376, (49, 36): 262596783764, (37, 9): 124403620, (11, 10): 11, (35, 25): 183579396, (50, 35): 2250829575120, (24, 18): 134596, (14, 5): 2002, (38, 6): 2760681, (36, 18): 9075135300, (25, 19): 177100, (39, 7): 15380937, (37, 19): 17672631900, (26, 8): 1562275, (44, 36): 177232627, (48, 21): 22314239266528, (38, 24): 9669554100, (27, 5): 80730, (44, 38): 7059052, (49, 16): 3348108992991, (39, 29): 635745396, (4, 1): 4, (28, 6): 376740, (50, 23): 108043253365600, (31, 11): 84672315, (5, 4): 5, (29, 7): 1560780, (16, 4): 1820, (40, 1): 40, (30, 20): 30045015, (19, 17): 171, (17, 1): 17, (41, 28): 17620076360, (31, 17): 265182525, (46, 27): 4154246671960, (20, 10): 184756, (18, 6): 18564, (42, 27): 98672427616, (47, 41): 10737573, (40, 39): 40, (21, 11): 352716, (43, 18): 608359048206, (32, 29): 4960, (44, 21): 2012616400080, (33, 24): 38567100, (23, 5): 33649, (47, 19): 6973199770790, (45, 24): 3773655750150, (34, 31): 5984, (39, 38): 39, (11, 3): 165, (35, 30): 324632, (14, 12): 91, (12, 4): 495, (36, 25): 600805296, (47, 5): 1533939, (25, 20): 53130, (15, 9): 5005, (13, 9): 715, (37, 28): 124403620, (26, 19): 657800, (48, 12): 69668534468, (38, 19): 35345263800, (27, 26): 27, (44, 12): 21090682613, (49, 9): 2054455634, (39, 26): 8122425444, (43, 23): 960566918220, (50, 14): 937845656300, (6, 2): 15, (44, 35): 708930508, (45, 41): 148995, (41, 5): 749398, (31, 30): 31, (46, 34): 38910617655, (20, 17): 1140, (18, 1): 18, (42, 2): 861, (47, 27): 9762479679106, (21, 20): 21, (43, 11): 5752004349, (32, 20): 225792840, (46, 4): 163185, (35, 33): 595, (33, 17): 1166803110, (23, 2): 253, (47, 1): 47, (45, 17): 1103068603890, (34, 22): 548354040, (32, 10): 64512240, (35, 7): 6724520, (33, 11): 193536720, (48, 45): 17296, (12, 3): 220, (45, 43): 990, (47, 44): 16215, (49, 40): 2054455634, (13, 2): 78, (37, 5): 435897, (50, 47): 19600, (24, 6): 134596, (48, 3): 17296, (38, 10): 472733756, (27, 19): 2220075, (25, 7): 480700, (49, 2): 1176, (39, 19): 68923264410, (28, 20): 3108105, (26, 4): 14950, (43, 33): 1917334783, (44, 42): 946, (48, 25): 30957699535776, (29, 25): 23751, (27, 9): 4686825, (6, 5): 6, (30, 6): 593775, (41, 14): 35240152720, (31, 7): 2629575, (46, 37): 1101716330, (42, 13): 25518731280, (16, 8): 12870, (40, 21): 131282408400, (19, 5): 11628, (41, 16): 103077446706, (22, 18): 7315, (46, 15): 511738760544, (20, 6): 38760, (44, 11): 7669339132, (42, 23): 446775310800, (47, 14): 341643774795, (21, 7): 116280, (36, 33): 7140, (34, 17): 2333606220, (8, 4): 70, (32, 1): 32, (37, 36): 37, (35, 12): 834451800, (9, 1): 9, (33, 12): 354817320, (48, 36): 69668534468, (36, 15): 5567902560, (10, 6): 210, (34, 11): 286097760, (49, 33): 3348108992991, (37, 14): 6107086800, (35, 18): 4537567650, (50, 38): 121399651100, (24, 13): 2496144, (38, 13): 5414950296, (36, 21): 5567902560, (25, 8): 1081575, (15, 5): 3003, (39, 8): 61523748, (28, 19): 6906900, (26, 15): 7726160, (48, 16): 2254848913647, (29, 18): 34597290, (27, 14): 20058300, (44, 18): 1029530696964, (49, 29): 28277527346376, (30, 9): 14307150, (28, 9): 6906900, (50, 26): 121548660036300, (31, 12): 141120525, (46, 44): 1035, (29, 12): 51895935, (41, 12): 7898654920, (16, 15): 16, (40, 28): 5586853480, (30, 19): 54627300, (19, 10): 92378, (17, 14): 680, (41, 25): 103077446706, (22, 21): 22, (46, 22): 7890371113950, (20, 13): 77520, (44, 2): 946, (18, 13): 8568, (42, 30): 11058116888, (23, 16): 245157, (40, 34): 3838380, (45, 3): 14190, (43, 31): 15338678264, (32, 24): 10518300, (22, 15): 170544, (45, 36): 886163135, (44, 24): 1761039350070, (43, 36): 32224114, (33, 5): 237336, (23, 14): 817190, (38, 34): 73815, (45, 29): 646626422970, (10, 1): 10, (34, 2): 561, (35, 27): 23535820, (50, 33): 9847379391150, (24, 20): 10626, (14, 11): 364, (38, 4): 73815, (36, 28): 30260340, (25, 17): 1081575, (15, 2): 105, (39, 1): 39, (37, 17): 15905368710, (26, 22): 14950, (48, 23): 30957699535776, (38, 30): 48903492, (27, 7): 888030, (49, 22): 49699896548176, (39, 31): 61523748, (4, 3): 4, (50, 21): 67327446062800, (44, 40): 135751, (5, 2): 10, (29, 5): 118755, (16, 6): 8008, (40, 3): 9880, (30, 26): 27405, (50, 9): 2505433700, (17, 7): 19448, (41, 2): 820, (31, 19): 141120525, (46, 25): 6943526580276, (18, 4): 3060, (42, 25): 254661927156, (47, 28): 6973199770790, (21, 9): 293930, (43, 20): 960566918220, (32, 31): 32, (22, 6): 74613, (46, 3): 15180, (44, 23): 2012616400080, (33, 30): 5456, (23, 7): 245157, (38, 37): 38, (45, 22): 4116715363800, (10, 8): 45, (34, 29): 278256, (39, 32): 15380937, (11, 5): 462, (48, 40): 377348994, (12, 6): 924, (36, 27): 94143280, (15, 11): 1365, (13, 7): 1716, (37, 26): 854992152, (40, 15): 40225345056, (26, 17): 3124550, (24, 1): 24, (48, 14): 482320623240, (38, 17): 28781143380, (49, 15): 1575580702584, (39, 20): 68923264410, (45, 8): 215553195, (47, 46): 47, (40, 10): 847660528, (30, 29): 30, (7, 5): 21, (31, 24): 2629575, (46, 32): 239877544005, (20, 19): 20, (42, 32): 1471442973, (47, 16): 1503232609098, (40, 16): 62852101650, (21, 18): 1330, (43, 13): 36576848168, (32, 22): 64512240, (46, 10): 4076350421, (44, 14): 114955808528, (33, 23): 92561040, (47, 3): 16215, (45, 15): 344867425584, (34, 20): 1391975640, (32, 12): 225792840, (35, 9): 70607460, (33, 9): 38567100, (48, 47): 48, (36, 2): 630, (34, 14): 1391975640, (49, 46): 18424, (37, 3): 7770, (26, 24): 325, (50, 45): 2118760, (24, 8): 735471, (48, 5): 1712304, (38, 8): 48903492, (27, 21): 296010, (25, 5): 53130, (39, 13): 8122425444, (45, 42): 14190, (28, 22): 376740, (2, 1): 2, (26, 2): 325, (50, 7): 99884400, (44, 32): 21090682613, (48, 27): 22314239266528, (29, 23): 475020, (27, 11): 13037895, (49, 26): 58343356817424, (30, 4): 27405, (43, 41): 903, (28, 12): 30421755, (7, 2): 21, (31, 1): 31, (46, 43): 15180, (42, 11): 4280561376, (16, 10): 8008, (40, 23): 88732378800, (19, 7): 50388, (43, 2): 903, (17, 11): 12376, (41, 22): 244662670200, (22, 16): 74613, (46, 13): 101766230790, (44, 5): 1086008, (18, 16): 153, (42, 21): 538257874440, (23, 21): 253, (47, 8): 314457495, (21, 5): 20349, (36, 35): 36, (43, 24): 800472431850, (8, 6): 28, (32, 3): 4960, (22, 10): 646646, (37, 34): 7770, (35, 14): 2319959400, (9, 7): 36, (33, 2): 528, (48, 38): 6540715896, (36, 9): 94143280, (10, 4): 210, (34, 9): 52451256, (49, 39): 8217822536, (37, 12): 1852482996, (11, 9): 55, (35, 20): 3247943160, (50, 36): 937845656300, (24, 15): 1307504, (14, 6): 3003, (38, 3): 8436, (36, 23): 2310789600, (25, 14): 4457400, (15, 7): 6435, (39, 10): 635745396, (41, 37): 101270, (37, 22): 9364199760, (26, 13): 10400600, (48, 18): 7309837001104, (29, 16): 67863915, (42, 6): 5245786, (49, 19): 18851684897584, (30, 15): 155117520, (28, 11): 21474180, (45, 10): 3190187286, (31, 14): 265182525, (29, 10): 20030010, (16, 1): 16, (40, 30): 847660528, (30, 17): 119759850, (19, 12): 50388, (43, 38): 962598, (17, 12): 6188, (41, 31): 1121099408, (31, 20): 84672315, (46, 20): 5608233007146, (20, 15): 15504, (42, 34): 118030185, (18, 11): 31824, (41, 8): 95548245, (23, 18): 33649, (40, 36): 91390, (21, 14): 116280, (45, 1): 45, (43, 17): 421171648758, (32, 26): 906192, (22, 13): 497420, (43, 35): 145008513, (44, 26): 1029530696964, (9, 8): 9, (33, 27): 1107568, (23, 8): 490314, (38, 32): 2760681, (45, 27): 1715884494940, (39, 37): 741, (35, 29): 1623160, (24, 22): 276, (14, 9): 2002, (12, 9): 220, (36, 30): 1947792, (25, 23): 300, (15, 12): 455, (39, 3): 9139, (13, 12): 13, (37, 31): 2324784, (26, 20): 230230, (48, 9): 1677106640, (38, 28): 472733756, (27, 25): 351, (47, 38): 1362649145, (49, 20): 28277527346376, (39, 25): 15084504396, (28, 2): 378, (47, 35): 52251400851, (50, 19): 30405943383200, (29, 3): 3654, (40, 5): 658008, (30, 24): 593775, (17, 5): 6188, (31, 29): 465, (46, 31): 511738760544, (43, 37): 6096454, (18, 2): 153, (42, 7): 26978328, (47, 30): 2741188875414, (47, 17): 2741188875414, (43, 40): 12341, (34, 33): 34, (32, 17): 565722720, (22, 4): 7315, (46, 1): 46, (44, 17): 686353797976, (33, 28): 237336, (23, 1): 23, (47, 4): 178365, (45, 20): 3169870830126, (34, 27): 5379616, (39, 34): 575757, (11, 7): 330, (35, 2): 595, (48, 42): 12271512, (36, 5): 376992, (25, 24): 25, (49, 43): 13983816, (13, 5): 1287, (37, 24): 3562467300, (50, 48): 1225, (24, 3): 2024, (38, 23): 15471286560, (42, 41): 42, (50, 24): 121548660036300, (25, 2): 300, (49, 13): 262596783764, (39, 22): 51021117810, (41, 39): 820, (28, 25): 3276, (40, 11): 2311801440, (50, 10): 10272278170, (29, 28): 29, (40, 12): 5586853480, (30, 3): 4060, (41, 9): 350343565, (31, 26): 169911, (46, 38): 260932815, (42, 14): 52860229080, (40, 18): 113380261800, (21, 16): 20349, (43, 15): 151532656696, (17, 16): 17, (41, 19): 244662670200, (46, 8): 260932815, (48, 34): 482320623240, (42, 36): 5245786, (33, 21): 354817320, (47, 13): 140676848445, (45, 13): 73006209045, (34, 18): 2203961430, (8, 1): 8, (32, 14): 471435600, (35, 11): 417225900, (33, 15): 1037158320, (48, 33): 1093260079344, (36, 12): 1251677700, (34, 12): 548354040, (49, 44): 1906884, (37, 1): 37, (35, 17): 4537567650, (50, 18): 18053528883775, (24, 10): 1961256, (48, 7): 73629072, (38, 14): 9669554100, (27, 23): 17550, (25, 11): 4457400, (49, 6): 13983816, (39, 15): 25140840660, (28, 16): 30421755, (50, 5): 2118760, (48, 29): 11541847896480, (29, 21): 4292145, (27, 13): 20058300, (47, 36): 17417133617, (49, 24): 63205303218876, (30, 10): 30045015, (28, 14): 40116600, (50, 31): 30405943383200, (31, 3): 4495, (46, 41): 1370754, (29, 15): 77558760, (42, 9): 445891810, (16, 12): 1820, (40, 25): 40225345056, (45, 38): 45379620, (19, 9): 92378, (43, 4): 123410, (17, 9): 24310, (41, 20): 269128937220, (46, 19): 4154246671960, (20, 2): 190, (44, 7): 38320568, (18, 14): 3060, (42, 19): 446775310800, (41, 10): 1121099408, (47, 10): 5178066751, (21, 3): 1330, (45, 6): 8145060, (43, 26): 421171648758, (32, 5): 201376, (22, 8): 319770, (37, 32): 435897, (44, 29): 229911617056, (9, 5): 126, (23, 13): 1144066, (36, 11): 600805296, (10, 2): 45, (34, 7): 5379616, (49, 37): 92263734836, (37, 10): 348330136, (35, 22): 1476337800, (50, 34): 4923689695575, (24, 17): 346104, (14, 4): 1001, (38, 1): 38, (50, 49): 50, (36, 17): 8597496600, (44, 15): 229911617056, (25, 12): 5200300, (15, 1): 15, (39, 4): 82251, (37, 20): 15905368710, (26, 11): 7726160, (48, 20): 16735679449896, (38, 27): 1203322288, (27, 2): 351, (49, 17): 6499270398159, (30, 13): 119759850, (41, 33): 95548245, (28, 5): 98280, (40, 9): 273438880, (50, 22): 88749815264600, (31, 8): 7888725, (29, 8): 4292145, (16, 3): 560, (30, 23): 2035800, (19, 14): 11628, (17, 2): 136, (41, 29): 7898654920, (31, 22): 20160075, (46, 26): 5608233007146, (20, 9): 167960, (18, 9): 48620, (42, 26): 166509721602, (40, 38): 780, (21, 12): 293930, (50, 43): 99884400, (43, 19): 800472431850, (32, 28): 35960, (22, 3): 1540, (42, 38): 111930, (33, 25): 13884156, (23, 10): 1144066, (45, 25): 3169870830126, (34, 30): 46376, (35, 31): 52360, (44, 20): 1761039350070, (42, 28): 52860229080, (12, 11): 12, (36, 24): 1251677700, (25, 21): 12650, (15, 14): 15, (13, 10): 286, (37, 29): 38608020, (26, 18): 1562275, (44, 37): 38320568, (48, 11): 22595200368, (38, 18): 33578000610, (49, 10): 8217822536, (39, 27): 3910797436, (50, 17): 9847379391150, (29, 1): 29, (40, 7): 18643560, (41, 6): 4496388, (46, 29): 1749695026860, (20, 16): 4845, (42, 5): 850668, (47, 24): 16123801841550, (45, 40): 1221759, (43, 8): 145008513, (32, 19): 347373600, (46, 7): 53524680, (44, 19): 1408831480056, (33, 18): 1037158320, (23, 3): 1771, (47, 6): 10737573, (45, 18): 1715884494940, (34, 25): 52451256, (32, 9): 28048800, (35, 4): 52360, (47, 23): 16123801841550, (12, 2): 66, (36, 7): 8347680, (49, 41): 450978066, (13, 3): 286, (37, 6): 2324784, (50, 46): 230300, (24, 5): 42504, (48, 2): 1128, (38, 21): 28781143380, (27, 16): 13037895, (44, 13): 51915526432, (49, 3): 18424, (39, 16): 37711260990, (28, 27): 28, (26, 7): 657800, (50, 8): 536878650, (43, 34): 563921995, (48, 24): 32247603683100, (29, 26): 3654, (6, 4): 15, (30, 1): 30, (41, 35): 4496388, (7, 1): 7, (31, 4): 31465, (46, 36): 4076350421, (42, 12): 11058116888, (40, 20): 137846528820, (19, 2): 171, (43, 1): 43, (41, 17): 151584480450, (46, 14): 239877544005, (20, 5): 15504, (44, 10): 2481256778, (42, 22): 513791607420, (47, 15): 751616304549, (36, 32): 58905, (34, 16): 2203961430, (8, 3): 56, (49, 48): 49, (35, 13): 1476337800, (9, 2): 36, (33, 13): 573166440, (48, 35): 192928249296, (36, 14): 3796297200, (34, 10): 131128140, (49, 34): 1575580702584, (37, 15): 9364199760, (35, 19): 4059928950, (50, 41): 2505433700, (24, 12): 2704156, (14, 3): 364, (38, 12): 2707475148, (36, 20): 7307872110, (25, 9): 2042975, (49, 4): 211876, (39, 9): 211915132, (28, 18): 13123110, (26, 14): 9657700, (50, 3): 19600, (44, 43): 44, (48, 31): 4244421484512, (29, 19): 20030010, (27, 15): 17383860, (49, 30): 18851684897584, (30, 8): 5852925, (28, 8): 3108105, (50, 29): 67327446062800, (31, 13): 206253075, (29, 13): 67863915, (16, 14): 120, (40, 27): 12033222880, (30, 18): 86493225, (19, 11): 75582, (43, 6): 6096454, (17, 15): 136, (41, 26): 63432274896, (22, 20): 231, (46, 17): 1749695026860, (20, 12): 125970, (44, 1): 44, (18, 12): 18564, (42, 17): 254661927156, (23, 17): 100947, (40, 33): 18643560, (21, 1): 21, (45, 4): 148995, (43, 28): 151532656696, (32, 7): 3365856, (22, 14): 319770, (44, 31): 51915526432, (33, 6): 1107568, (23, 15): 490314, (45, 30): 344867425584, (34, 5): 278256, (41, 40): 41, (37, 8): 38608020, (35, 24): 417225900, (50, 32): 18053528883775, (24, 19): 42504, (14, 10): 1001, (38, 7): 12620256, (36, 19): 8597496600, (25, 18): 480700, (15, 3): 455, (39, 6): 3262623, (37, 18): 17672631900, (26, 9): 3124550, (48, 22): 27385657281648, (38, 25): 5414950296, (27, 4): 17550, (49, 23): 58343356817424, (39, 28): 1676056044, (4, 2): 6, (28, 7): 1184040, (50, 20): 47129212243960, (31, 10): 44352165, (5, 3): 10, (29, 6): 475020, (41, 11): 3159461968, (50, 30): 47129212243960, (16, 5): 4368, (40, 2): 780, (30, 21): 14307150, (19, 16): 969, (41, 3): 10660, (31, 16): 300540195, (46, 24): 7890371113950, (20, 11): 167960, (45, 33): 28760021745, (18, 7): 31824, (42, 24): 353697121050, (47, 29): 4568648125690, (21, 10): 352716, (43, 21): 1052049481860, (32, 30): 496, (22, 1): 22, (46, 2): 1035, (44, 22): 2104098963720, (33, 31): 528, (23, 4): 8855, (38, 36): 703, (45, 23): 4116715363800, (34, 28): 1344904, (39, 33): 3262623, (11, 2): 55, (35, 1): 35, (14, 13): 14, (12, 5): 792, (36, 26): 254186856, (47, 45): 1081, (15, 8): 6435, (13, 8): 1287, (37, 27): 348330136, (26, 16): 5311735, (48, 13): 192928249296, (38, 16): 22239974430, (47, 32): 751616304549, (49, 8): 450978066, (39, 21): 62359143990, (50, 15): 2250829575120, (44, 41): 13244, (6, 3): 20, (30, 28): 435, (41, 4): 101270, (31, 25): 736281, (46, 35): 13340783196, (20, 18): 190, (42, 29): 25518731280, (42, 3): 11480, (47, 26): 12551759587422, (21, 19): 210, (43, 10): 1917334783, (32, 21): 129024480, (46, 5): 1370754, (35, 32): 6545, (33, 16): 1166803110, (45, 44): 45, (45, 16): 646626422970, (44, 6): 7059052, (34, 23): 286097760, (32, 11): 129024480, (43, 22): 1052049481860, (35, 6): 1623160, (33, 10): 92561040, (48, 46): 1128, (36, 1): 36, (49, 47): 1176, (13, 1): 13, (37, 4): 66045, (50, 44): 15890700, (24, 7): 346104, (48, 4): 194580, (38, 11): 1203322288, (27, 18): 4686825, (47, 43): 178365, (25, 6): 177100, (49, 1): 49, (39, 18): 62359143990, (50, 40): 10272278170, (28, 21): 1184040, (26, 5): 65780, (50, 6): 15890700, (48, 26): 27385657281648, (29, 24): 118755, (27, 8): 2220075, (49, 27): 49699896548176, (30, 7): 2035800} def nCr(self, n, r): if n == r or r == 0: return 1 if n < r: return 0 if self.dic.get((n, r), None) is None: self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r) return self.dic[(n,r)] def show(self): print(self.dic) def main(): N, A, B = tuple(map(int, input().split(' '))) v = sorted(list(map(int, input().split(' '))), reverse=True) print(sum(v[:A])/A) if v[0] == v[A-1]: comb = Comb(N) print(sum([comb.nCr(v.count(v[A-1]), r) for r in range(A, B+1)])) else: print(comb.nCr(v.count(v[A-1]), v[:A].count(v[A-1]))) if __name__ == '__main__': main()
s807331127
p03776
u076936237
1491005917
Python
Python (3.4.3)
py
Runtime Error
329
21116
24397
import statistics as stats from math import factorial from scipy.special import comb class Comb: def __init__(self, N): super(Comb, self).__init__() self.dic = {(7, 3): 35, (31, 6): 736281, (46, 42): 163185, (42, 33): 445891810, (41, 13): 17620076360, (16, 9): 11440, (40, 22): 113380261800, (19, 4): 3876, (43, 3): 12341, (41, 23): 202112640600, (22, 19): 1540, (46, 12): 38910617655, (20, 7): 77520, (44, 4): 135751, (42, 20): 513791607420, (47, 9): 1362649145, (21, 6): 54264, (36, 34): 630, (43, 25): 608359048206, (8, 5): 56, (32, 2): 496, (37, 35): 666, (35, 15): 3247943160, (33, 3): 5456, (48, 37): 22595200368, (36, 8): 30260340, (10, 7): 120, (34, 8): 18156204, (49, 32): 6499270398159, (42, 10): 1471442973, (37, 13): 3562467300, (35, 21): 2319959400, (50, 39): 37353738800, (24, 14): 1961256, (14, 1): 14, (38, 2): 703, (36, 22): 3796297200, (25, 15): 3268760, (15, 4): 1365, (39, 11): 1676056044, (37, 23): 6107086800, (26, 12): 9657700, (50, 1): 50, (48, 17): 4244421484512, (29, 17): 51895935, (3, 2): 3, (27, 1): 27, (49, 28): 39049918716424, (30, 14): 145422675, (28, 10): 13123110, (50, 27): 108043253365600, (31, 15): 300540195, (46, 45): 46, (29, 11): 34597290, (40, 29): 2311801440, (30, 16): 145422675, (19, 13): 27132, (17, 13): 2380, (41, 24): 151584480450, (31, 21): 44352165, (46, 23): 8233430727600, (20, 14): 38760, (44, 3): 13244, (18, 10): 43758, (42, 31): 4280561376, (23, 19): 8855, (40, 35): 658008, (21, 15): 54264, (45, 2): 990, (43, 30): 36576848168, (43, 39): 123410, (32, 25): 3365856, (22, 12): 646646, (44, 25): 1408831480056, (33, 4): 40920, (23, 9): 817190, (38, 35): 8436, (45, 28): 1103068603890, (34, 3): 5984, (35, 26): 70607460, (24, 21): 2024, (14, 8): 3003, (38, 5): 501942, (12, 8): 495, (36, 29): 8347680, (25, 16): 2042975, (15, 13): 105, (41, 36): 749398, (37, 16): 12875774670, (40, 14): 23206929840, (26, 23): 2600, (48, 8): 377348994, (38, 31): 12620256, (27, 6): 296010, (49, 21): 39049918716424, (39, 30): 211915132, (28, 1): 28, (45, 9): 886163135, (5, 1): 5, (29, 4): 23751, (16, 7): 11440, (40, 4): 91390, (30, 27): 4060, (19, 18): 19, (17, 6): 12376, (41, 1): 41, (31, 18): 206253075, (46, 30): 991493848554, (42, 35): 26978328, (18, 5): 8568, (41, 15): 63432274896, (47, 31): 1503232609098, (21, 8): 203490, (34, 32): 561, (32, 16): 601080390, (22, 7): 170544, (44, 16): 416714805914, (33, 29): 40920, (23, 6): 100947, (45, 37): 215553195, (45, 21): 3773655750150, (10, 9): 10, (34, 26): 18156204, (39, 35): 82251, (11, 4): 330, (35, 3): 6545, (44, 34): 2481256778, (48, 41): 73629072, (12, 7): 792, (36, 4): 58905, (43, 42): 43, (15, 10): 3003, (13, 6): 1716, (37, 25): 1852482996, (24, 2): 276, (48, 15): 1093260079344, (38, 22): 22239974430, (25, 3): 2300, (49, 14): 675248872536, (39, 23): 37711260990, (28, 24): 20475, (50, 13): 354860518600, (45, 34): 10150595910, (49, 11): 29135916264, (6, 1): 6, (30, 2): 435, (45, 32): 73006209045, (7, 4): 35, (31, 27): 31465, (46, 33): 101766230790, (42, 1): 42, (40, 17): 88732378800, (21, 17): 5985, (19, 1): 19, (43, 12): 15338678264, (32, 23): 28048800, (46, 11): 13340783196, (35, 34): 35, (33, 22): 193536720, (47, 18): 4568648125690, (47, 2): 1081, (45, 14): 166871334960, (34, 21): 927983760, (32, 13): 347373600, (35, 8): 23535820, (33, 8): 13884156, (48, 32): 2254848913647, (36, 3): 7140, (34, 15): 1855967520, (49, 45): 211876, (37, 2): 666, (26, 25): 26, (50, 42): 536878650, (24, 9): 1307504, (48, 6): 12271512, (38, 9): 163011640, (27, 20): 888030, (25, 4): 12650, (49, 7): 85900584, (39, 12): 3910797436, (41, 38): 10660, (28, 23): 98280, (26, 3): 2600, (50, 4): 230300, (48, 28): 16735679449896, (29, 22): 1560780, (27, 10): 8436285, (49, 25): 63205303218876, (30, 5): 142506, (28, 13): 37442160, (45, 11): 10150595910, (46, 40): 9366819, (42, 8): 118030185, (16, 11): 4368, (40, 24): 62852101650, (44, 39): 1086008, (19, 6): 27132, (43, 5): 962598, (17, 10): 19448, (41, 21): 269128937220, (22, 17): 26334, (46, 18): 2818953098830, (20, 1): 20, (42, 37): 850668, (18, 17): 18, (42, 18): 353697121050, (23, 20): 1771, (47, 11): 17417133617, (21, 4): 5985, (45, 7): 45379620, (43, 27): 265182149218, (8, 7): 8, (32, 4): 35960, (22, 11): 705432, (37, 33): 66045, (44, 28): 416714805914, (9, 6): 84, (33, 1): 33, (48, 39): 1677106640, (47, 40): 62891499, (36, 10): 254186856, (10, 5): 252, (34, 6): 1344904, (49, 38): 29135916264, (37, 11): 854992152, (11, 8): 165, (35, 23): 834451800, (50, 37): 354860518600, (24, 16): 735471, (14, 7): 3432, (44, 33): 7669339132, (36, 16): 7307872110, (25, 13): 5200300, (15, 6): 5005, (39, 5): 575757, (37, 21): 12875774670, (26, 10): 5311735, (48, 19): 11541847896480, (38, 26): 2707475148, (27, 3): 2925, (47, 39): 314457495, (49, 18): 11554258485616, (30, 12): 86493225, (28, 4): 20475, (50, 25): 126410606437752, (31, 9): 20160075, (29, 9): 10015005, (16, 2): 120, (40, 31): 273438880, (30, 22): 5852925, (19, 15): 3876, (17, 3): 680, (41, 30): 3159461968, (31, 23): 7888725, (46, 21): 6943526580276, (20, 8): 125970, (18, 8): 43758, (33, 32): 33, (40, 37): 9880, (21, 13): 203490, (50, 12): 121399651100, (43, 16): 265182149218, (32, 27): 201376, (22, 2): 231, (43, 32): 5752004349, (44, 27): 686353797976, (33, 26): 4272048, (23, 11): 1352078, (38, 33): 501942, (45, 26): 2438362177020, (34, 1): 34, (39, 36): 9139, (11, 1): 11, (35, 28): 6724520, (24, 23): 24, (12, 10): 66, (36, 31): 376992, (44, 8): 177232627, (25, 22): 2300, (39, 2): 741, (13, 11): 78, (37, 30): 10295472, (26, 21): 65780, (48, 10): 6540715896, (38, 29): 163011640, (42, 40): 861, (27, 24): 2925, (47, 34): 140676848445, (39, 24): 25140840660, (41, 32): 350343565, (28, 3): 3276, (50, 16): 4923689695575, (29, 2): 406, (47, 33): 341643774795, (40, 6): 3838380, (30, 25): 142506, (17, 4): 2380, (41, 7): 22481940, (31, 28): 4495, (46, 28): 2818953098830, (18, 3): 816, (42, 4): 111930, (47, 25): 14833897694226, (47, 21): 12551759587422, (43, 9): 563921995, (32, 18): 471435600, (22, 5): 26334, (46, 6): 9366819, (42, 39): 11480, (33, 19): 818809200, (47, 7): 62891499, (47, 42): 1533939, (45, 19): 2438362177020, (34, 24): 131128140, (32, 8): 10518300, (11, 6): 462, (35, 5): 324632, (48, 43): 1712304, (12, 1): 12, (36, 6): 1947792, (49, 42): 85900584, (13, 4): 715, (37, 7): 10295472, (48, 44): 194580, (24, 4): 10626, (48, 1): 48, (38, 20): 33578000610, (27, 17): 8436285, (25, 1): 25, (49, 12): 92263734836, (39, 17): 51021117810, (28, 26): 378, (26, 6): 230230, (50, 11): 37353738800, (29, 27): 406, (47, 37): 5178066751, (40, 13): 12033222880, (7, 6): 7, (31, 5): 169911, (46, 39): 53524680, (47, 20): 9762479679106, (42, 15): 98672427616, (40, 19): 131282408400, (45, 39): 8145060, (19, 3): 969, (43, 14): 78378960360, (41, 18): 202112640600, (46, 9): 1101716330, (20, 4): 4845, (44, 9): 708930508, (33, 20): 573166440, (47, 12): 52251400851, (45, 12): 28760021745, (34, 19): 1855967520, (8, 2): 28, (32, 15): 565722720, (35, 10): 183579396, (9, 3): 84, (33, 14): 818809200, (47, 22): 14833897694226, (36, 13): 2310789600, (34, 13): 927983760, (49, 35): 675248872536, (35, 16): 4059928950, (45, 35): 3190187286, (24, 11): 2496144, (14, 2): 91, (38, 15): 15471286560, (27, 22): 80730, (25, 10): 3268760, (49, 5): 1906884, (39, 14): 15084504396, (28, 17): 21474180, (26, 1): 26, (50, 2): 1225, (48, 30): 7309837001104, (29, 20): 10015005, (3, 1): 3, (27, 12): 17383860, (49, 31): 11554258485616, (30, 11): 54627300, (41, 34): 22481940, (28, 15): 37442160, (40, 8): 76904685, (50, 28): 88749815264600, (31, 2): 465, (29, 14): 77558760, (16, 13): 560, (40, 26): 23206929840, (19, 8): 75582, (43, 7): 32224114, (17, 8): 24310, (41, 27): 35240152720, (46, 16): 991493848554, (20, 3): 1140, (18, 15): 816, (42, 16): 166509721602, (23, 22): 23, (40, 32): 76904685, (21, 2): 210, (45, 5): 1221759, (43, 29): 78378960360, (32, 6): 906192, (22, 9): 497420, (44, 30): 114955808528, (9, 4): 126, (33, 7): 4272048, (23, 12): 1352078, (45, 31): 166871334960, (10, 3): 120, (34, 4): 46376, (49, 36): 262596783764, (37, 9): 124403620, (11, 10): 11, (35, 25): 183579396, (50, 35): 2250829575120, (24, 18): 134596, (14, 5): 2002, (38, 6): 2760681, (36, 18): 9075135300, (25, 19): 177100, (39, 7): 15380937, (37, 19): 17672631900, (26, 8): 1562275, (44, 36): 177232627, (48, 21): 22314239266528, (38, 24): 9669554100, (27, 5): 80730, (44, 38): 7059052, (49, 16): 3348108992991, (39, 29): 635745396, (4, 1): 4, (28, 6): 376740, (50, 23): 108043253365600, (31, 11): 84672315, (5, 4): 5, (29, 7): 1560780, (16, 4): 1820, (40, 1): 40, (30, 20): 30045015, (19, 17): 171, (17, 1): 17, (41, 28): 17620076360, (31, 17): 265182525, (46, 27): 4154246671960, (20, 10): 184756, (18, 6): 18564, (42, 27): 98672427616, (47, 41): 10737573, (40, 39): 40, (21, 11): 352716, (43, 18): 608359048206, (32, 29): 4960, (44, 21): 2012616400080, (33, 24): 38567100, (23, 5): 33649, (47, 19): 6973199770790, (45, 24): 3773655750150, (34, 31): 5984, (39, 38): 39, (11, 3): 165, (35, 30): 324632, (14, 12): 91, (12, 4): 495, (36, 25): 600805296, (47, 5): 1533939, (25, 20): 53130, (15, 9): 5005, (13, 9): 715, (37, 28): 124403620, (26, 19): 657800, (48, 12): 69668534468, (38, 19): 35345263800, (27, 26): 27, (44, 12): 21090682613, (49, 9): 2054455634, (39, 26): 8122425444, (43, 23): 960566918220, (50, 14): 937845656300, (6, 2): 15, (44, 35): 708930508, (45, 41): 148995, (41, 5): 749398, (31, 30): 31, (46, 34): 38910617655, (20, 17): 1140, (18, 1): 18, (42, 2): 861, (47, 27): 9762479679106, (21, 20): 21, (43, 11): 5752004349, (32, 20): 225792840, (46, 4): 163185, (35, 33): 595, (33, 17): 1166803110, (23, 2): 253, (47, 1): 47, (45, 17): 1103068603890, (34, 22): 548354040, (32, 10): 64512240, (35, 7): 6724520, (33, 11): 193536720, (48, 45): 17296, (12, 3): 220, (45, 43): 990, (47, 44): 16215, (49, 40): 2054455634, (13, 2): 78, (37, 5): 435897, (50, 47): 19600, (24, 6): 134596, (48, 3): 17296, (38, 10): 472733756, (27, 19): 2220075, (25, 7): 480700, (49, 2): 1176, (39, 19): 68923264410, (28, 20): 3108105, (26, 4): 14950, (43, 33): 1917334783, (44, 42): 946, (48, 25): 30957699535776, (29, 25): 23751, (27, 9): 4686825, (6, 5): 6, (30, 6): 593775, (41, 14): 35240152720, (31, 7): 2629575, (46, 37): 1101716330, (42, 13): 25518731280, (16, 8): 12870, (40, 21): 131282408400, (19, 5): 11628, (41, 16): 103077446706, (22, 18): 7315, (46, 15): 511738760544, (20, 6): 38760, (44, 11): 7669339132, (42, 23): 446775310800, (47, 14): 341643774795, (21, 7): 116280, (36, 33): 7140, (34, 17): 2333606220, (8, 4): 70, (32, 1): 32, (37, 36): 37, (35, 12): 834451800, (9, 1): 9, (33, 12): 354817320, (48, 36): 69668534468, (36, 15): 5567902560, (10, 6): 210, (34, 11): 286097760, (49, 33): 3348108992991, (37, 14): 6107086800, (35, 18): 4537567650, (50, 38): 121399651100, (24, 13): 2496144, (38, 13): 5414950296, (36, 21): 5567902560, (25, 8): 1081575, (15, 5): 3003, (39, 8): 61523748, (28, 19): 6906900, (26, 15): 7726160, (48, 16): 2254848913647, (29, 18): 34597290, (27, 14): 20058300, (44, 18): 1029530696964, (49, 29): 28277527346376, (30, 9): 14307150, (28, 9): 6906900, (50, 26): 121548660036300, (31, 12): 141120525, (46, 44): 1035, (29, 12): 51895935, (41, 12): 7898654920, (16, 15): 16, (40, 28): 5586853480, (30, 19): 54627300, (19, 10): 92378, (17, 14): 680, (41, 25): 103077446706, (22, 21): 22, (46, 22): 7890371113950, (20, 13): 77520, (44, 2): 946, (18, 13): 8568, (42, 30): 11058116888, (23, 16): 245157, (40, 34): 3838380, (45, 3): 14190, (43, 31): 15338678264, (32, 24): 10518300, (22, 15): 170544, (45, 36): 886163135, (44, 24): 1761039350070, (43, 36): 32224114, (33, 5): 237336, (23, 14): 817190, (38, 34): 73815, (45, 29): 646626422970, (10, 1): 10, (34, 2): 561, (35, 27): 23535820, (50, 33): 9847379391150, (24, 20): 10626, (14, 11): 364, (38, 4): 73815, (36, 28): 30260340, (25, 17): 1081575, (15, 2): 105, (39, 1): 39, (37, 17): 15905368710, (26, 22): 14950, (48, 23): 30957699535776, (38, 30): 48903492, (27, 7): 888030, (49, 22): 49699896548176, (39, 31): 61523748, (4, 3): 4, (50, 21): 67327446062800, (44, 40): 135751, (5, 2): 10, (29, 5): 118755, (16, 6): 8008, (40, 3): 9880, (30, 26): 27405, (50, 9): 2505433700, (17, 7): 19448, (41, 2): 820, (31, 19): 141120525, (46, 25): 6943526580276, (18, 4): 3060, (42, 25): 254661927156, (47, 28): 6973199770790, (21, 9): 293930, (43, 20): 960566918220, (32, 31): 32, (22, 6): 74613, (46, 3): 15180, (44, 23): 2012616400080, (33, 30): 5456, (23, 7): 245157, (38, 37): 38, (45, 22): 4116715363800, (10, 8): 45, (34, 29): 278256, (39, 32): 15380937, (11, 5): 462, (48, 40): 377348994, (12, 6): 924, (36, 27): 94143280, (15, 11): 1365, (13, 7): 1716, (37, 26): 854992152, (40, 15): 40225345056, (26, 17): 3124550, (24, 1): 24, (48, 14): 482320623240, (38, 17): 28781143380, (49, 15): 1575580702584, (39, 20): 68923264410, (45, 8): 215553195, (47, 46): 47, (40, 10): 847660528, (30, 29): 30, (7, 5): 21, (31, 24): 2629575, (46, 32): 239877544005, (20, 19): 20, (42, 32): 1471442973, (47, 16): 1503232609098, (40, 16): 62852101650, (21, 18): 1330, (43, 13): 36576848168, (32, 22): 64512240, (46, 10): 4076350421, (44, 14): 114955808528, (33, 23): 92561040, (47, 3): 16215, (45, 15): 344867425584, (34, 20): 1391975640, (32, 12): 225792840, (35, 9): 70607460, (33, 9): 38567100, (48, 47): 48, (36, 2): 630, (34, 14): 1391975640, (49, 46): 18424, (37, 3): 7770, (26, 24): 325, (50, 45): 2118760, (24, 8): 735471, (48, 5): 1712304, (38, 8): 48903492, (27, 21): 296010, (25, 5): 53130, (39, 13): 8122425444, (45, 42): 14190, (28, 22): 376740, (2, 1): 2, (26, 2): 325, (50, 7): 99884400, (44, 32): 21090682613, (48, 27): 22314239266528, (29, 23): 475020, (27, 11): 13037895, (49, 26): 58343356817424, (30, 4): 27405, (43, 41): 903, (28, 12): 30421755, (7, 2): 21, (31, 1): 31, (46, 43): 15180, (42, 11): 4280561376, (16, 10): 8008, (40, 23): 88732378800, (19, 7): 50388, (43, 2): 903, (17, 11): 12376, (41, 22): 244662670200, (22, 16): 74613, (46, 13): 101766230790, (44, 5): 1086008, (18, 16): 153, (42, 21): 538257874440, (23, 21): 253, (47, 8): 314457495, (21, 5): 20349, (36, 35): 36, (43, 24): 800472431850, (8, 6): 28, (32, 3): 4960, (22, 10): 646646, (37, 34): 7770, (35, 14): 2319959400, (9, 7): 36, (33, 2): 528, (48, 38): 6540715896, (36, 9): 94143280, (10, 4): 210, (34, 9): 52451256, (49, 39): 8217822536, (37, 12): 1852482996, (11, 9): 55, (35, 20): 3247943160, (50, 36): 937845656300, (24, 15): 1307504, (14, 6): 3003, (38, 3): 8436, (36, 23): 2310789600, (25, 14): 4457400, (15, 7): 6435, (39, 10): 635745396, (41, 37): 101270, (37, 22): 9364199760, (26, 13): 10400600, (48, 18): 7309837001104, (29, 16): 67863915, (42, 6): 5245786, (49, 19): 18851684897584, (30, 15): 155117520, (28, 11): 21474180, (45, 10): 3190187286, (31, 14): 265182525, (29, 10): 20030010, (16, 1): 16, (40, 30): 847660528, (30, 17): 119759850, (19, 12): 50388, (43, 38): 962598, (17, 12): 6188, (41, 31): 1121099408, (31, 20): 84672315, (46, 20): 5608233007146, (20, 15): 15504, (42, 34): 118030185, (18, 11): 31824, (41, 8): 95548245, (23, 18): 33649, (40, 36): 91390, (21, 14): 116280, (45, 1): 45, (43, 17): 421171648758, (32, 26): 906192, (22, 13): 497420, (43, 35): 145008513, (44, 26): 1029530696964, (9, 8): 9, (33, 27): 1107568, (23, 8): 490314, (38, 32): 2760681, (45, 27): 1715884494940, (39, 37): 741, (35, 29): 1623160, (24, 22): 276, (14, 9): 2002, (12, 9): 220, (36, 30): 1947792, (25, 23): 300, (15, 12): 455, (39, 3): 9139, (13, 12): 13, (37, 31): 2324784, (26, 20): 230230, (48, 9): 1677106640, (38, 28): 472733756, (27, 25): 351, (47, 38): 1362649145, (49, 20): 28277527346376, (39, 25): 15084504396, (28, 2): 378, (47, 35): 52251400851, (50, 19): 30405943383200, (29, 3): 3654, (40, 5): 658008, (30, 24): 593775, (17, 5): 6188, (31, 29): 465, (46, 31): 511738760544, (43, 37): 6096454, (18, 2): 153, (42, 7): 26978328, (47, 30): 2741188875414, (47, 17): 2741188875414, (43, 40): 12341, (34, 33): 34, (32, 17): 565722720, (22, 4): 7315, (46, 1): 46, (44, 17): 686353797976, (33, 28): 237336, (23, 1): 23, (47, 4): 178365, (45, 20): 3169870830126, (34, 27): 5379616, (39, 34): 575757, (11, 7): 330, (35, 2): 595, (48, 42): 12271512, (36, 5): 376992, (25, 24): 25, (49, 43): 13983816, (13, 5): 1287, (37, 24): 3562467300, (50, 48): 1225, (24, 3): 2024, (38, 23): 15471286560, (42, 41): 42, (50, 24): 121548660036300, (25, 2): 300, (49, 13): 262596783764, (39, 22): 51021117810, (41, 39): 820, (28, 25): 3276, (40, 11): 2311801440, (50, 10): 10272278170, (29, 28): 29, (40, 12): 5586853480, (30, 3): 4060, (41, 9): 350343565, (31, 26): 169911, (46, 38): 260932815, (42, 14): 52860229080, (40, 18): 113380261800, (21, 16): 20349, (43, 15): 151532656696, (17, 16): 17, (41, 19): 244662670200, (46, 8): 260932815, (48, 34): 482320623240, (42, 36): 5245786, (33, 21): 354817320, (47, 13): 140676848445, (45, 13): 73006209045, (34, 18): 2203961430, (8, 1): 8, (32, 14): 471435600, (35, 11): 417225900, (33, 15): 1037158320, (48, 33): 1093260079344, (36, 12): 1251677700, (34, 12): 548354040, (49, 44): 1906884, (37, 1): 37, (35, 17): 4537567650, (50, 18): 18053528883775, (24, 10): 1961256, (48, 7): 73629072, (38, 14): 9669554100, (27, 23): 17550, (25, 11): 4457400, (49, 6): 13983816, (39, 15): 25140840660, (28, 16): 30421755, (50, 5): 2118760, (48, 29): 11541847896480, (29, 21): 4292145, (27, 13): 20058300, (47, 36): 17417133617, (49, 24): 63205303218876, (30, 10): 30045015, (28, 14): 40116600, (50, 31): 30405943383200, (31, 3): 4495, (46, 41): 1370754, (29, 15): 77558760, (42, 9): 445891810, (16, 12): 1820, (40, 25): 40225345056, (45, 38): 45379620, (19, 9): 92378, (43, 4): 123410, (17, 9): 24310, (41, 20): 269128937220, (46, 19): 4154246671960, (20, 2): 190, (44, 7): 38320568, (18, 14): 3060, (42, 19): 446775310800, (41, 10): 1121099408, (47, 10): 5178066751, (21, 3): 1330, (45, 6): 8145060, (43, 26): 421171648758, (32, 5): 201376, (22, 8): 319770, (37, 32): 435897, (44, 29): 229911617056, (9, 5): 126, (23, 13): 1144066, (36, 11): 600805296, (10, 2): 45, (34, 7): 5379616, (49, 37): 92263734836, (37, 10): 348330136, (35, 22): 1476337800, (50, 34): 4923689695575, (24, 17): 346104, (14, 4): 1001, (38, 1): 38, (50, 49): 50, (36, 17): 8597496600, (44, 15): 229911617056, (25, 12): 5200300, (15, 1): 15, (39, 4): 82251, (37, 20): 15905368710, (26, 11): 7726160, (48, 20): 16735679449896, (38, 27): 1203322288, (27, 2): 351, (49, 17): 6499270398159, (30, 13): 119759850, (41, 33): 95548245, (28, 5): 98280, (40, 9): 273438880, (50, 22): 88749815264600, (31, 8): 7888725, (29, 8): 4292145, (16, 3): 560, (30, 23): 2035800, (19, 14): 11628, (17, 2): 136, (41, 29): 7898654920, (31, 22): 20160075, (46, 26): 5608233007146, (20, 9): 167960, (18, 9): 48620, (42, 26): 166509721602, (40, 38): 780, (21, 12): 293930, (50, 43): 99884400, (43, 19): 800472431850, (32, 28): 35960, (22, 3): 1540, (42, 38): 111930, (33, 25): 13884156, (23, 10): 1144066, (45, 25): 3169870830126, (34, 30): 46376, (35, 31): 52360, (44, 20): 1761039350070, (42, 28): 52860229080, (12, 11): 12, (36, 24): 1251677700, (25, 21): 12650, (15, 14): 15, (13, 10): 286, (37, 29): 38608020, (26, 18): 1562275, (44, 37): 38320568, (48, 11): 22595200368, (38, 18): 33578000610, (49, 10): 8217822536, (39, 27): 3910797436, (50, 17): 9847379391150, (29, 1): 29, (40, 7): 18643560, (41, 6): 4496388, (46, 29): 1749695026860, (20, 16): 4845, (42, 5): 850668, (47, 24): 16123801841550, (45, 40): 1221759, (43, 8): 145008513, (32, 19): 347373600, (46, 7): 53524680, (44, 19): 1408831480056, (33, 18): 1037158320, (23, 3): 1771, (47, 6): 10737573, (45, 18): 1715884494940, (34, 25): 52451256, (32, 9): 28048800, (35, 4): 52360, (47, 23): 16123801841550, (12, 2): 66, (36, 7): 8347680, (49, 41): 450978066, (13, 3): 286, (37, 6): 2324784, (50, 46): 230300, (24, 5): 42504, (48, 2): 1128, (38, 21): 28781143380, (27, 16): 13037895, (44, 13): 51915526432, (49, 3): 18424, (39, 16): 37711260990, (28, 27): 28, (26, 7): 657800, (50, 8): 536878650, (43, 34): 563921995, (48, 24): 32247603683100, (29, 26): 3654, (6, 4): 15, (30, 1): 30, (41, 35): 4496388, (7, 1): 7, (31, 4): 31465, (46, 36): 4076350421, (42, 12): 11058116888, (40, 20): 137846528820, (19, 2): 171, (43, 1): 43, (41, 17): 151584480450, (46, 14): 239877544005, (20, 5): 15504, (44, 10): 2481256778, (42, 22): 513791607420, (47, 15): 751616304549, (36, 32): 58905, (34, 16): 2203961430, (8, 3): 56, (49, 48): 49, (35, 13): 1476337800, (9, 2): 36, (33, 13): 573166440, (48, 35): 192928249296, (36, 14): 3796297200, (34, 10): 131128140, (49, 34): 1575580702584, (37, 15): 9364199760, (35, 19): 4059928950, (50, 41): 2505433700, (24, 12): 2704156, (14, 3): 364, (38, 12): 2707475148, (36, 20): 7307872110, (25, 9): 2042975, (49, 4): 211876, (39, 9): 211915132, (28, 18): 13123110, (26, 14): 9657700, (50, 3): 19600, (44, 43): 44, (48, 31): 4244421484512, (29, 19): 20030010, (27, 15): 17383860, (49, 30): 18851684897584, (30, 8): 5852925, (28, 8): 3108105, (50, 29): 67327446062800, (31, 13): 206253075, (29, 13): 67863915, (16, 14): 120, (40, 27): 12033222880, (30, 18): 86493225, (19, 11): 75582, (43, 6): 6096454, (17, 15): 136, (41, 26): 63432274896, (22, 20): 231, (46, 17): 1749695026860, (20, 12): 125970, (44, 1): 44, (18, 12): 18564, (42, 17): 254661927156, (23, 17): 100947, (40, 33): 18643560, (21, 1): 21, (45, 4): 148995, (43, 28): 151532656696, (32, 7): 3365856, (22, 14): 319770, (44, 31): 51915526432, (33, 6): 1107568, (23, 15): 490314, (45, 30): 344867425584, (34, 5): 278256, (41, 40): 41, (37, 8): 38608020, (35, 24): 417225900, (50, 32): 18053528883775, (24, 19): 42504, (14, 10): 1001, (38, 7): 12620256, (36, 19): 8597496600, (25, 18): 480700, (15, 3): 455, (39, 6): 3262623, (37, 18): 17672631900, (26, 9): 3124550, (48, 22): 27385657281648, (38, 25): 5414950296, (27, 4): 17550, (49, 23): 58343356817424, (39, 28): 1676056044, (4, 2): 6, (28, 7): 1184040, (50, 20): 47129212243960, (31, 10): 44352165, (5, 3): 10, (29, 6): 475020, (41, 11): 3159461968, (50, 30): 47129212243960, (16, 5): 4368, (40, 2): 780, (30, 21): 14307150, (19, 16): 969, (41, 3): 10660, (31, 16): 300540195, (46, 24): 7890371113950, (20, 11): 167960, (45, 33): 28760021745, (18, 7): 31824, (42, 24): 353697121050, (47, 29): 4568648125690, (21, 10): 352716, (43, 21): 1052049481860, (32, 30): 496, (22, 1): 22, (46, 2): 1035, (44, 22): 2104098963720, (33, 31): 528, (23, 4): 8855, (38, 36): 703, (45, 23): 4116715363800, (34, 28): 1344904, (39, 33): 3262623, (11, 2): 55, (35, 1): 35, (14, 13): 14, (12, 5): 792, (36, 26): 254186856, (47, 45): 1081, (15, 8): 6435, (13, 8): 1287, (37, 27): 348330136, (26, 16): 5311735, (48, 13): 192928249296, (38, 16): 22239974430, (47, 32): 751616304549, (49, 8): 450978066, (39, 21): 62359143990, (50, 15): 2250829575120, (44, 41): 13244, (6, 3): 20, (30, 28): 435, (41, 4): 101270, (31, 25): 736281, (46, 35): 13340783196, (20, 18): 190, (42, 29): 25518731280, (42, 3): 11480, (47, 26): 12551759587422, (21, 19): 210, (43, 10): 1917334783, (32, 21): 129024480, (46, 5): 1370754, (35, 32): 6545, (33, 16): 1166803110, (45, 44): 45, (45, 16): 646626422970, (44, 6): 7059052, (34, 23): 286097760, (32, 11): 129024480, (43, 22): 1052049481860, (35, 6): 1623160, (33, 10): 92561040, (48, 46): 1128, (36, 1): 36, (49, 47): 1176, (13, 1): 13, (37, 4): 66045, (50, 44): 15890700, (24, 7): 346104, (48, 4): 194580, (38, 11): 1203322288, (27, 18): 4686825, (47, 43): 178365, (25, 6): 177100, (49, 1): 49, (39, 18): 62359143990, (50, 40): 10272278170, (28, 21): 1184040, (26, 5): 65780, (50, 6): 15890700, (48, 26): 27385657281648, (29, 24): 118755, (27, 8): 2220075, (49, 27): 49699896548176, (30, 7): 2035800} def nCr(self, n, r): if n == r or r == 0: return 1 if self.dic.get((n, r), None) is None: self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r) return self.dic[(n,r)] def show(self): print(self.dic) def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] max_ = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_bmin_cnt = v_list.count(bucket_min) b_bmin_cnt = max_bucket.count(bucket_min) all_max_cnt = v_list.count(max_) c = Comb(N) print(max_ave) if all_max_cnt <= A: print(comb(all_bmin_cnt, b_bmin_cnt, exact=True)) else: num = 0 for r in range(A, B+1): num += comb(all_max_cnt, r, exact=True) print(num) if __name__ == '__main__': main()
s398735924
p03776
u076936237
1491005438
Python
Python (3.4.3)
py
Runtime Error
142
6816
24366
import statistics as stats from math import factorial class Comb: def __init__(self, N): super(Comb, self).__init__() self.dic = {(7, 3): 35, (31, 6): 736281, (46, 42): 163185, (42, 33): 445891810, (41, 13): 17620076360, (16, 9): 11440, (40, 22): 113380261800, (19, 4): 3876, (43, 3): 12341, (41, 23): 202112640600, (22, 19): 1540, (46, 12): 38910617655, (20, 7): 77520, (44, 4): 135751, (42, 20): 513791607420, (47, 9): 1362649145, (21, 6): 54264, (36, 34): 630, (43, 25): 608359048206, (8, 5): 56, (32, 2): 496, (37, 35): 666, (35, 15): 3247943160, (33, 3): 5456, (48, 37): 22595200368, (36, 8): 30260340, (10, 7): 120, (34, 8): 18156204, (49, 32): 6499270398159, (42, 10): 1471442973, (37, 13): 3562467300, (35, 21): 2319959400, (50, 39): 37353738800, (24, 14): 1961256, (14, 1): 14, (38, 2): 703, (36, 22): 3796297200, (25, 15): 3268760, (15, 4): 1365, (39, 11): 1676056044, (37, 23): 6107086800, (26, 12): 9657700, (50, 1): 50, (48, 17): 4244421484512, (29, 17): 51895935, (3, 2): 3, (27, 1): 27, (49, 28): 39049918716424, (30, 14): 145422675, (28, 10): 13123110, (50, 27): 108043253365600, (31, 15): 300540195, (46, 45): 46, (29, 11): 34597290, (40, 29): 2311801440, (30, 16): 145422675, (19, 13): 27132, (17, 13): 2380, (41, 24): 151584480450, (31, 21): 44352165, (46, 23): 8233430727600, (20, 14): 38760, (44, 3): 13244, (18, 10): 43758, (42, 31): 4280561376, (23, 19): 8855, (40, 35): 658008, (21, 15): 54264, (45, 2): 990, (43, 30): 36576848168, (43, 39): 123410, (32, 25): 3365856, (22, 12): 646646, (44, 25): 1408831480056, (33, 4): 40920, (23, 9): 817190, (38, 35): 8436, (45, 28): 1103068603890, (34, 3): 5984, (35, 26): 70607460, (24, 21): 2024, (14, 8): 3003, (38, 5): 501942, (12, 8): 495, (36, 29): 8347680, (25, 16): 2042975, (15, 13): 105, (41, 36): 749398, (37, 16): 12875774670, (40, 14): 23206929840, (26, 23): 2600, (48, 8): 377348994, (38, 31): 12620256, (27, 6): 296010, (49, 21): 39049918716424, (39, 30): 211915132, (28, 1): 28, (45, 9): 886163135, (5, 1): 5, (29, 4): 23751, (16, 7): 11440, (40, 4): 91390, (30, 27): 4060, (19, 18): 19, (17, 6): 12376, (41, 1): 41, (31, 18): 206253075, (46, 30): 991493848554, (42, 35): 26978328, (18, 5): 8568, (41, 15): 63432274896, (47, 31): 1503232609098, (21, 8): 203490, (34, 32): 561, (32, 16): 601080390, (22, 7): 170544, (44, 16): 416714805914, (33, 29): 40920, (23, 6): 100947, (45, 37): 215553195, (45, 21): 3773655750150, (10, 9): 10, (34, 26): 18156204, (39, 35): 82251, (11, 4): 330, (35, 3): 6545, (44, 34): 2481256778, (48, 41): 73629072, (12, 7): 792, (36, 4): 58905, (43, 42): 43, (15, 10): 3003, (13, 6): 1716, (37, 25): 1852482996, (24, 2): 276, (48, 15): 1093260079344, (38, 22): 22239974430, (25, 3): 2300, (49, 14): 675248872536, (39, 23): 37711260990, (28, 24): 20475, (50, 13): 354860518600, (45, 34): 10150595910, (49, 11): 29135916264, (6, 1): 6, (30, 2): 435, (45, 32): 73006209045, (7, 4): 35, (31, 27): 31465, (46, 33): 101766230790, (42, 1): 42, (40, 17): 88732378800, (21, 17): 5985, (19, 1): 19, (43, 12): 15338678264, (32, 23): 28048800, (46, 11): 13340783196, (35, 34): 35, (33, 22): 193536720, (47, 18): 4568648125690, (47, 2): 1081, (45, 14): 166871334960, (34, 21): 927983760, (32, 13): 347373600, (35, 8): 23535820, (33, 8): 13884156, (48, 32): 2254848913647, (36, 3): 7140, (34, 15): 1855967520, (49, 45): 211876, (37, 2): 666, (26, 25): 26, (50, 42): 536878650, (24, 9): 1307504, (48, 6): 12271512, (38, 9): 163011640, (27, 20): 888030, (25, 4): 12650, (49, 7): 85900584, (39, 12): 3910797436, (41, 38): 10660, (28, 23): 98280, (26, 3): 2600, (50, 4): 230300, (48, 28): 16735679449896, (29, 22): 1560780, (27, 10): 8436285, (49, 25): 63205303218876, (30, 5): 142506, (28, 13): 37442160, (45, 11): 10150595910, (46, 40): 9366819, (42, 8): 118030185, (16, 11): 4368, (40, 24): 62852101650, (44, 39): 1086008, (19, 6): 27132, (43, 5): 962598, (17, 10): 19448, (41, 21): 269128937220, (22, 17): 26334, (46, 18): 2818953098830, (20, 1): 20, (42, 37): 850668, (18, 17): 18, (42, 18): 353697121050, (23, 20): 1771, (47, 11): 17417133617, (21, 4): 5985, (45, 7): 45379620, (43, 27): 265182149218, (8, 7): 8, (32, 4): 35960, (22, 11): 705432, (37, 33): 66045, (44, 28): 416714805914, (9, 6): 84, (33, 1): 33, (48, 39): 1677106640, (47, 40): 62891499, (36, 10): 254186856, (10, 5): 252, (34, 6): 1344904, (49, 38): 29135916264, (37, 11): 854992152, (11, 8): 165, (35, 23): 834451800, (50, 37): 354860518600, (24, 16): 735471, (14, 7): 3432, (44, 33): 7669339132, (36, 16): 7307872110, (25, 13): 5200300, (15, 6): 5005, (39, 5): 575757, (37, 21): 12875774670, (26, 10): 5311735, (48, 19): 11541847896480, (38, 26): 2707475148, (27, 3): 2925, (47, 39): 314457495, (49, 18): 11554258485616, (30, 12): 86493225, (28, 4): 20475, (50, 25): 126410606437752, (31, 9): 20160075, (29, 9): 10015005, (16, 2): 120, (40, 31): 273438880, (30, 22): 5852925, (19, 15): 3876, (17, 3): 680, (41, 30): 3159461968, (31, 23): 7888725, (46, 21): 6943526580276, (20, 8): 125970, (18, 8): 43758, (33, 32): 33, (40, 37): 9880, (21, 13): 203490, (50, 12): 121399651100, (43, 16): 265182149218, (32, 27): 201376, (22, 2): 231, (43, 32): 5752004349, (44, 27): 686353797976, (33, 26): 4272048, (23, 11): 1352078, (38, 33): 501942, (45, 26): 2438362177020, (34, 1): 34, (39, 36): 9139, (11, 1): 11, (35, 28): 6724520, (24, 23): 24, (12, 10): 66, (36, 31): 376992, (44, 8): 177232627, (25, 22): 2300, (39, 2): 741, (13, 11): 78, (37, 30): 10295472, (26, 21): 65780, (48, 10): 6540715896, (38, 29): 163011640, (42, 40): 861, (27, 24): 2925, (47, 34): 140676848445, (39, 24): 25140840660, (41, 32): 350343565, (28, 3): 3276, (50, 16): 4923689695575, (29, 2): 406, (47, 33): 341643774795, (40, 6): 3838380, (30, 25): 142506, (17, 4): 2380, (41, 7): 22481940, (31, 28): 4495, (46, 28): 2818953098830, (18, 3): 816, (42, 4): 111930, (47, 25): 14833897694226, (47, 21): 12551759587422, (43, 9): 563921995, (32, 18): 471435600, (22, 5): 26334, (46, 6): 9366819, (42, 39): 11480, (33, 19): 818809200, (47, 7): 62891499, (47, 42): 1533939, (45, 19): 2438362177020, (34, 24): 131128140, (32, 8): 10518300, (11, 6): 462, (35, 5): 324632, (48, 43): 1712304, (12, 1): 12, (36, 6): 1947792, (49, 42): 85900584, (13, 4): 715, (37, 7): 10295472, (48, 44): 194580, (24, 4): 10626, (48, 1): 48, (38, 20): 33578000610, (27, 17): 8436285, (25, 1): 25, (49, 12): 92263734836, (39, 17): 51021117810, (28, 26): 378, (26, 6): 230230, (50, 11): 37353738800, (29, 27): 406, (47, 37): 5178066751, (40, 13): 12033222880, (7, 6): 7, (31, 5): 169911, (46, 39): 53524680, (47, 20): 9762479679106, (42, 15): 98672427616, (40, 19): 131282408400, (45, 39): 8145060, (19, 3): 969, (43, 14): 78378960360, (41, 18): 202112640600, (46, 9): 1101716330, (20, 4): 4845, (44, 9): 708930508, (33, 20): 573166440, (47, 12): 52251400851, (45, 12): 28760021745, (34, 19): 1855967520, (8, 2): 28, (32, 15): 565722720, (35, 10): 183579396, (9, 3): 84, (33, 14): 818809200, (47, 22): 14833897694226, (36, 13): 2310789600, (34, 13): 927983760, (49, 35): 675248872536, (35, 16): 4059928950, (45, 35): 3190187286, (24, 11): 2496144, (14, 2): 91, (38, 15): 15471286560, (27, 22): 80730, (25, 10): 3268760, (49, 5): 1906884, (39, 14): 15084504396, (28, 17): 21474180, (26, 1): 26, (50, 2): 1225, (48, 30): 7309837001104, (29, 20): 10015005, (3, 1): 3, (27, 12): 17383860, (49, 31): 11554258485616, (30, 11): 54627300, (41, 34): 22481940, (28, 15): 37442160, (40, 8): 76904685, (50, 28): 88749815264600, (31, 2): 465, (29, 14): 77558760, (16, 13): 560, (40, 26): 23206929840, (19, 8): 75582, (43, 7): 32224114, (17, 8): 24310, (41, 27): 35240152720, (46, 16): 991493848554, (20, 3): 1140, (18, 15): 816, (42, 16): 166509721602, (23, 22): 23, (40, 32): 76904685, (21, 2): 210, (45, 5): 1221759, (43, 29): 78378960360, (32, 6): 906192, (22, 9): 497420, (44, 30): 114955808528, (9, 4): 126, (33, 7): 4272048, (23, 12): 1352078, (45, 31): 166871334960, (10, 3): 120, (34, 4): 46376, (49, 36): 262596783764, (37, 9): 124403620, (11, 10): 11, (35, 25): 183579396, (50, 35): 2250829575120, (24, 18): 134596, (14, 5): 2002, (38, 6): 2760681, (36, 18): 9075135300, (25, 19): 177100, (39, 7): 15380937, (37, 19): 17672631900, (26, 8): 1562275, (44, 36): 177232627, (48, 21): 22314239266528, (38, 24): 9669554100, (27, 5): 80730, (44, 38): 7059052, (49, 16): 3348108992991, (39, 29): 635745396, (4, 1): 4, (28, 6): 376740, (50, 23): 108043253365600, (31, 11): 84672315, (5, 4): 5, (29, 7): 1560780, (16, 4): 1820, (40, 1): 40, (30, 20): 30045015, (19, 17): 171, (17, 1): 17, (41, 28): 17620076360, (31, 17): 265182525, (46, 27): 4154246671960, (20, 10): 184756, (18, 6): 18564, (42, 27): 98672427616, (47, 41): 10737573, (40, 39): 40, (21, 11): 352716, (43, 18): 608359048206, (32, 29): 4960, (44, 21): 2012616400080, (33, 24): 38567100, (23, 5): 33649, (47, 19): 6973199770790, (45, 24): 3773655750150, (34, 31): 5984, (39, 38): 39, (11, 3): 165, (35, 30): 324632, (14, 12): 91, (12, 4): 495, (36, 25): 600805296, (47, 5): 1533939, (25, 20): 53130, (15, 9): 5005, (13, 9): 715, (37, 28): 124403620, (26, 19): 657800, (48, 12): 69668534468, (38, 19): 35345263800, (27, 26): 27, (44, 12): 21090682613, (49, 9): 2054455634, (39, 26): 8122425444, (43, 23): 960566918220, (50, 14): 937845656300, (6, 2): 15, (44, 35): 708930508, (45, 41): 148995, (41, 5): 749398, (31, 30): 31, (46, 34): 38910617655, (20, 17): 1140, (18, 1): 18, (42, 2): 861, (47, 27): 9762479679106, (21, 20): 21, (43, 11): 5752004349, (32, 20): 225792840, (46, 4): 163185, (35, 33): 595, (33, 17): 1166803110, (23, 2): 253, (47, 1): 47, (45, 17): 1103068603890, (34, 22): 548354040, (32, 10): 64512240, (35, 7): 6724520, (33, 11): 193536720, (48, 45): 17296, (12, 3): 220, (45, 43): 990, (47, 44): 16215, (49, 40): 2054455634, (13, 2): 78, (37, 5): 435897, (50, 47): 19600, (24, 6): 134596, (48, 3): 17296, (38, 10): 472733756, (27, 19): 2220075, (25, 7): 480700, (49, 2): 1176, (39, 19): 68923264410, (28, 20): 3108105, (26, 4): 14950, (43, 33): 1917334783, (44, 42): 946, (48, 25): 30957699535776, (29, 25): 23751, (27, 9): 4686825, (6, 5): 6, (30, 6): 593775, (41, 14): 35240152720, (31, 7): 2629575, (46, 37): 1101716330, (42, 13): 25518731280, (16, 8): 12870, (40, 21): 131282408400, (19, 5): 11628, (41, 16): 103077446706, (22, 18): 7315, (46, 15): 511738760544, (20, 6): 38760, (44, 11): 7669339132, (42, 23): 446775310800, (47, 14): 341643774795, (21, 7): 116280, (36, 33): 7140, (34, 17): 2333606220, (8, 4): 70, (32, 1): 32, (37, 36): 37, (35, 12): 834451800, (9, 1): 9, (33, 12): 354817320, (48, 36): 69668534468, (36, 15): 5567902560, (10, 6): 210, (34, 11): 286097760, (49, 33): 3348108992991, (37, 14): 6107086800, (35, 18): 4537567650, (50, 38): 121399651100, (24, 13): 2496144, (38, 13): 5414950296, (36, 21): 5567902560, (25, 8): 1081575, (15, 5): 3003, (39, 8): 61523748, (28, 19): 6906900, (26, 15): 7726160, (48, 16): 2254848913647, (29, 18): 34597290, (27, 14): 20058300, (44, 18): 1029530696964, (49, 29): 28277527346376, (30, 9): 14307150, (28, 9): 6906900, (50, 26): 121548660036300, (31, 12): 141120525, (46, 44): 1035, (29, 12): 51895935, (41, 12): 7898654920, (16, 15): 16, (40, 28): 5586853480, (30, 19): 54627300, (19, 10): 92378, (17, 14): 680, (41, 25): 103077446706, (22, 21): 22, (46, 22): 7890371113950, (20, 13): 77520, (44, 2): 946, (18, 13): 8568, (42, 30): 11058116888, (23, 16): 245157, (40, 34): 3838380, (45, 3): 14190, (43, 31): 15338678264, (32, 24): 10518300, (22, 15): 170544, (45, 36): 886163135, (44, 24): 1761039350070, (43, 36): 32224114, (33, 5): 237336, (23, 14): 817190, (38, 34): 73815, (45, 29): 646626422970, (10, 1): 10, (34, 2): 561, (35, 27): 23535820, (50, 33): 9847379391150, (24, 20): 10626, (14, 11): 364, (38, 4): 73815, (36, 28): 30260340, (25, 17): 1081575, (15, 2): 105, (39, 1): 39, (37, 17): 15905368710, (26, 22): 14950, (48, 23): 30957699535776, (38, 30): 48903492, (27, 7): 888030, (49, 22): 49699896548176, (39, 31): 61523748, (4, 3): 4, (50, 21): 67327446062800, (44, 40): 135751, (5, 2): 10, (29, 5): 118755, (16, 6): 8008, (40, 3): 9880, (30, 26): 27405, (50, 9): 2505433700, (17, 7): 19448, (41, 2): 820, (31, 19): 141120525, (46, 25): 6943526580276, (18, 4): 3060, (42, 25): 254661927156, (47, 28): 6973199770790, (21, 9): 293930, (43, 20): 960566918220, (32, 31): 32, (22, 6): 74613, (46, 3): 15180, (44, 23): 2012616400080, (33, 30): 5456, (23, 7): 245157, (38, 37): 38, (45, 22): 4116715363800, (10, 8): 45, (34, 29): 278256, (39, 32): 15380937, (11, 5): 462, (48, 40): 377348994, (12, 6): 924, (36, 27): 94143280, (15, 11): 1365, (13, 7): 1716, (37, 26): 854992152, (40, 15): 40225345056, (26, 17): 3124550, (24, 1): 24, (48, 14): 482320623240, (38, 17): 28781143380, (49, 15): 1575580702584, (39, 20): 68923264410, (45, 8): 215553195, (47, 46): 47, (40, 10): 847660528, (30, 29): 30, (7, 5): 21, (31, 24): 2629575, (46, 32): 239877544005, (20, 19): 20, (42, 32): 1471442973, (47, 16): 1503232609098, (40, 16): 62852101650, (21, 18): 1330, (43, 13): 36576848168, (32, 22): 64512240, (46, 10): 4076350421, (44, 14): 114955808528, (33, 23): 92561040, (47, 3): 16215, (45, 15): 344867425584, (34, 20): 1391975640, (32, 12): 225792840, (35, 9): 70607460, (33, 9): 38567100, (48, 47): 48, (36, 2): 630, (34, 14): 1391975640, (49, 46): 18424, (37, 3): 7770, (26, 24): 325, (50, 45): 2118760, (24, 8): 735471, (48, 5): 1712304, (38, 8): 48903492, (27, 21): 296010, (25, 5): 53130, (39, 13): 8122425444, (45, 42): 14190, (28, 22): 376740, (2, 1): 2, (26, 2): 325, (50, 7): 99884400, (44, 32): 21090682613, (48, 27): 22314239266528, (29, 23): 475020, (27, 11): 13037895, (49, 26): 58343356817424, (30, 4): 27405, (43, 41): 903, (28, 12): 30421755, (7, 2): 21, (31, 1): 31, (46, 43): 15180, (42, 11): 4280561376, (16, 10): 8008, (40, 23): 88732378800, (19, 7): 50388, (43, 2): 903, (17, 11): 12376, (41, 22): 244662670200, (22, 16): 74613, (46, 13): 101766230790, (44, 5): 1086008, (18, 16): 153, (42, 21): 538257874440, (23, 21): 253, (47, 8): 314457495, (21, 5): 20349, (36, 35): 36, (43, 24): 800472431850, (8, 6): 28, (32, 3): 4960, (22, 10): 646646, (37, 34): 7770, (35, 14): 2319959400, (9, 7): 36, (33, 2): 528, (48, 38): 6540715896, (36, 9): 94143280, (10, 4): 210, (34, 9): 52451256, (49, 39): 8217822536, (37, 12): 1852482996, (11, 9): 55, (35, 20): 3247943160, (50, 36): 937845656300, (24, 15): 1307504, (14, 6): 3003, (38, 3): 8436, (36, 23): 2310789600, (25, 14): 4457400, (15, 7): 6435, (39, 10): 635745396, (41, 37): 101270, (37, 22): 9364199760, (26, 13): 10400600, (48, 18): 7309837001104, (29, 16): 67863915, (42, 6): 5245786, (49, 19): 18851684897584, (30, 15): 155117520, (28, 11): 21474180, (45, 10): 3190187286, (31, 14): 265182525, (29, 10): 20030010, (16, 1): 16, (40, 30): 847660528, (30, 17): 119759850, (19, 12): 50388, (43, 38): 962598, (17, 12): 6188, (41, 31): 1121099408, (31, 20): 84672315, (46, 20): 5608233007146, (20, 15): 15504, (42, 34): 118030185, (18, 11): 31824, (41, 8): 95548245, (23, 18): 33649, (40, 36): 91390, (21, 14): 116280, (45, 1): 45, (43, 17): 421171648758, (32, 26): 906192, (22, 13): 497420, (43, 35): 145008513, (44, 26): 1029530696964, (9, 8): 9, (33, 27): 1107568, (23, 8): 490314, (38, 32): 2760681, (45, 27): 1715884494940, (39, 37): 741, (35, 29): 1623160, (24, 22): 276, (14, 9): 2002, (12, 9): 220, (36, 30): 1947792, (25, 23): 300, (15, 12): 455, (39, 3): 9139, (13, 12): 13, (37, 31): 2324784, (26, 20): 230230, (48, 9): 1677106640, (38, 28): 472733756, (27, 25): 351, (47, 38): 1362649145, (49, 20): 28277527346376, (39, 25): 15084504396, (28, 2): 378, (47, 35): 52251400851, (50, 19): 30405943383200, (29, 3): 3654, (40, 5): 658008, (30, 24): 593775, (17, 5): 6188, (31, 29): 465, (46, 31): 511738760544, (43, 37): 6096454, (18, 2): 153, (42, 7): 26978328, (47, 30): 2741188875414, (47, 17): 2741188875414, (43, 40): 12341, (34, 33): 34, (32, 17): 565722720, (22, 4): 7315, (46, 1): 46, (44, 17): 686353797976, (33, 28): 237336, (23, 1): 23, (47, 4): 178365, (45, 20): 3169870830126, (34, 27): 5379616, (39, 34): 575757, (11, 7): 330, (35, 2): 595, (48, 42): 12271512, (36, 5): 376992, (25, 24): 25, (49, 43): 13983816, (13, 5): 1287, (37, 24): 3562467300, (50, 48): 1225, (24, 3): 2024, (38, 23): 15471286560, (42, 41): 42, (50, 24): 121548660036300, (25, 2): 300, (49, 13): 262596783764, (39, 22): 51021117810, (41, 39): 820, (28, 25): 3276, (40, 11): 2311801440, (50, 10): 10272278170, (29, 28): 29, (40, 12): 5586853480, (30, 3): 4060, (41, 9): 350343565, (31, 26): 169911, (46, 38): 260932815, (42, 14): 52860229080, (40, 18): 113380261800, (21, 16): 20349, (43, 15): 151532656696, (17, 16): 17, (41, 19): 244662670200, (46, 8): 260932815, (48, 34): 482320623240, (42, 36): 5245786, (33, 21): 354817320, (47, 13): 140676848445, (45, 13): 73006209045, (34, 18): 2203961430, (8, 1): 8, (32, 14): 471435600, (35, 11): 417225900, (33, 15): 1037158320, (48, 33): 1093260079344, (36, 12): 1251677700, (34, 12): 548354040, (49, 44): 1906884, (37, 1): 37, (35, 17): 4537567650, (50, 18): 18053528883775, (24, 10): 1961256, (48, 7): 73629072, (38, 14): 9669554100, (27, 23): 17550, (25, 11): 4457400, (49, 6): 13983816, (39, 15): 25140840660, (28, 16): 30421755, (50, 5): 2118760, (48, 29): 11541847896480, (29, 21): 4292145, (27, 13): 20058300, (47, 36): 17417133617, (49, 24): 63205303218876, (30, 10): 30045015, (28, 14): 40116600, (50, 31): 30405943383200, (31, 3): 4495, (46, 41): 1370754, (29, 15): 77558760, (42, 9): 445891810, (16, 12): 1820, (40, 25): 40225345056, (45, 38): 45379620, (19, 9): 92378, (43, 4): 123410, (17, 9): 24310, (41, 20): 269128937220, (46, 19): 4154246671960, (20, 2): 190, (44, 7): 38320568, (18, 14): 3060, (42, 19): 446775310800, (41, 10): 1121099408, (47, 10): 5178066751, (21, 3): 1330, (45, 6): 8145060, (43, 26): 421171648758, (32, 5): 201376, (22, 8): 319770, (37, 32): 435897, (44, 29): 229911617056, (9, 5): 126, (23, 13): 1144066, (36, 11): 600805296, (10, 2): 45, (34, 7): 5379616, (49, 37): 92263734836, (37, 10): 348330136, (35, 22): 1476337800, (50, 34): 4923689695575, (24, 17): 346104, (14, 4): 1001, (38, 1): 38, (50, 49): 50, (36, 17): 8597496600, (44, 15): 229911617056, (25, 12): 5200300, (15, 1): 15, (39, 4): 82251, (37, 20): 15905368710, (26, 11): 7726160, (48, 20): 16735679449896, (38, 27): 1203322288, (27, 2): 351, (49, 17): 6499270398159, (30, 13): 119759850, (41, 33): 95548245, (28, 5): 98280, (40, 9): 273438880, (50, 22): 88749815264600, (31, 8): 7888725, (29, 8): 4292145, (16, 3): 560, (30, 23): 2035800, (19, 14): 11628, (17, 2): 136, (41, 29): 7898654920, (31, 22): 20160075, (46, 26): 5608233007146, (20, 9): 167960, (18, 9): 48620, (42, 26): 166509721602, (40, 38): 780, (21, 12): 293930, (50, 43): 99884400, (43, 19): 800472431850, (32, 28): 35960, (22, 3): 1540, (42, 38): 111930, (33, 25): 13884156, (23, 10): 1144066, (45, 25): 3169870830126, (34, 30): 46376, (35, 31): 52360, (44, 20): 1761039350070, (42, 28): 52860229080, (12, 11): 12, (36, 24): 1251677700, (25, 21): 12650, (15, 14): 15, (13, 10): 286, (37, 29): 38608020, (26, 18): 1562275, (44, 37): 38320568, (48, 11): 22595200368, (38, 18): 33578000610, (49, 10): 8217822536, (39, 27): 3910797436, (50, 17): 9847379391150, (29, 1): 29, (40, 7): 18643560, (41, 6): 4496388, (46, 29): 1749695026860, (20, 16): 4845, (42, 5): 850668, (47, 24): 16123801841550, (45, 40): 1221759, (43, 8): 145008513, (32, 19): 347373600, (46, 7): 53524680, (44, 19): 1408831480056, (33, 18): 1037158320, (23, 3): 1771, (47, 6): 10737573, (45, 18): 1715884494940, (34, 25): 52451256, (32, 9): 28048800, (35, 4): 52360, (47, 23): 16123801841550, (12, 2): 66, (36, 7): 8347680, (49, 41): 450978066, (13, 3): 286, (37, 6): 2324784, (50, 46): 230300, (24, 5): 42504, (48, 2): 1128, (38, 21): 28781143380, (27, 16): 13037895, (44, 13): 51915526432, (49, 3): 18424, (39, 16): 37711260990, (28, 27): 28, (26, 7): 657800, (50, 8): 536878650, (43, 34): 563921995, (48, 24): 32247603683100, (29, 26): 3654, (6, 4): 15, (30, 1): 30, (41, 35): 4496388, (7, 1): 7, (31, 4): 31465, (46, 36): 4076350421, (42, 12): 11058116888, (40, 20): 137846528820, (19, 2): 171, (43, 1): 43, (41, 17): 151584480450, (46, 14): 239877544005, (20, 5): 15504, (44, 10): 2481256778, (42, 22): 513791607420, (47, 15): 751616304549, (36, 32): 58905, (34, 16): 2203961430, (8, 3): 56, (49, 48): 49, (35, 13): 1476337800, (9, 2): 36, (33, 13): 573166440, (48, 35): 192928249296, (36, 14): 3796297200, (34, 10): 131128140, (49, 34): 1575580702584, (37, 15): 9364199760, (35, 19): 4059928950, (50, 41): 2505433700, (24, 12): 2704156, (14, 3): 364, (38, 12): 2707475148, (36, 20): 7307872110, (25, 9): 2042975, (49, 4): 211876, (39, 9): 211915132, (28, 18): 13123110, (26, 14): 9657700, (50, 3): 19600, (44, 43): 44, (48, 31): 4244421484512, (29, 19): 20030010, (27, 15): 17383860, (49, 30): 18851684897584, (30, 8): 5852925, (28, 8): 3108105, (50, 29): 67327446062800, (31, 13): 206253075, (29, 13): 67863915, (16, 14): 120, (40, 27): 12033222880, (30, 18): 86493225, (19, 11): 75582, (43, 6): 6096454, (17, 15): 136, (41, 26): 63432274896, (22, 20): 231, (46, 17): 1749695026860, (20, 12): 125970, (44, 1): 44, (18, 12): 18564, (42, 17): 254661927156, (23, 17): 100947, (40, 33): 18643560, (21, 1): 21, (45, 4): 148995, (43, 28): 151532656696, (32, 7): 3365856, (22, 14): 319770, (44, 31): 51915526432, (33, 6): 1107568, (23, 15): 490314, (45, 30): 344867425584, (34, 5): 278256, (41, 40): 41, (37, 8): 38608020, (35, 24): 417225900, (50, 32): 18053528883775, (24, 19): 42504, (14, 10): 1001, (38, 7): 12620256, (36, 19): 8597496600, (25, 18): 480700, (15, 3): 455, (39, 6): 3262623, (37, 18): 17672631900, (26, 9): 3124550, (48, 22): 27385657281648, (38, 25): 5414950296, (27, 4): 17550, (49, 23): 58343356817424, (39, 28): 1676056044, (4, 2): 6, (28, 7): 1184040, (50, 20): 47129212243960, (31, 10): 44352165, (5, 3): 10, (29, 6): 475020, (41, 11): 3159461968, (50, 30): 47129212243960, (16, 5): 4368, (40, 2): 780, (30, 21): 14307150, (19, 16): 969, (41, 3): 10660, (31, 16): 300540195, (46, 24): 7890371113950, (20, 11): 167960, (45, 33): 28760021745, (18, 7): 31824, (42, 24): 353697121050, (47, 29): 4568648125690, (21, 10): 352716, (43, 21): 1052049481860, (32, 30): 496, (22, 1): 22, (46, 2): 1035, (44, 22): 2104098963720, (33, 31): 528, (23, 4): 8855, (38, 36): 703, (45, 23): 4116715363800, (34, 28): 1344904, (39, 33): 3262623, (11, 2): 55, (35, 1): 35, (14, 13): 14, (12, 5): 792, (36, 26): 254186856, (47, 45): 1081, (15, 8): 6435, (13, 8): 1287, (37, 27): 348330136, (26, 16): 5311735, (48, 13): 192928249296, (38, 16): 22239974430, (47, 32): 751616304549, (49, 8): 450978066, (39, 21): 62359143990, (50, 15): 2250829575120, (44, 41): 13244, (6, 3): 20, (30, 28): 435, (41, 4): 101270, (31, 25): 736281, (46, 35): 13340783196, (20, 18): 190, (42, 29): 25518731280, (42, 3): 11480, (47, 26): 12551759587422, (21, 19): 210, (43, 10): 1917334783, (32, 21): 129024480, (46, 5): 1370754, (35, 32): 6545, (33, 16): 1166803110, (45, 44): 45, (45, 16): 646626422970, (44, 6): 7059052, (34, 23): 286097760, (32, 11): 129024480, (43, 22): 1052049481860, (35, 6): 1623160, (33, 10): 92561040, (48, 46): 1128, (36, 1): 36, (49, 47): 1176, (13, 1): 13, (37, 4): 66045, (50, 44): 15890700, (24, 7): 346104, (48, 4): 194580, (38, 11): 1203322288, (27, 18): 4686825, (47, 43): 178365, (25, 6): 177100, (49, 1): 49, (39, 18): 62359143990, (50, 40): 10272278170, (28, 21): 1184040, (26, 5): 65780, (50, 6): 15890700, (48, 26): 27385657281648, (29, 24): 118755, (27, 8): 2220075, (49, 27): 49699896548176, (30, 7): 2035800} def nCr(self, n, r): if n == r or r == 0: return 1 if self.dic.get((n, r), None) is None: self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r) return self.dic[(n,r)] def show(self): print(self.dic) def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] max_ = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_bmin_cnt = v_list.count(bucket_min) b_bmin_cnt = max_bucket.count(bucket_min) all_max_cnt = v_list.count(max_) comb = Comb(N) print(max_ave) if all_max_cnt <= A: pass print(comb.nCr(all_bmin_cnt, b_bmin_cnt)) else: num = 0 for r in range(A, B+1): num += comb.nCr(all_max_cnt, r) print(num) if __name__ == '__main__': main()
s838671251
p03776
u076936237
1491005217
Python
Python (3.4.3)
py
Runtime Error
97
6172
1151
import statistics as stats from math import factorial class Comb: def __init__(self, N): super(Comb, self).__init__() self.dic = {} for i in range(1, N+1): for j in range(1, i+1): self.nCr(i, j) def nCr(self, n, r): if n == r or r == 0: return 1 if self.dic.get((n, r), None) is None: self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r) return self.dic[(n,r)] def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] max_ = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_bmin_cnt = v_list.count(bucket_min) b_bmin_cnt = max_bucket.count(bucket_min) all_max_cnt = v_list.count(max_) comb = Comb(N) print(max_ave) if all_max_cnt <= A: print(comb.nCr(all_bmin_cnt, b_bmin_cnt)) else: num = 0 for r in range(A, B+1): num += comb.nCr(all_max_cnt, r) print(num) if __name__ == '__main__': main()
s029831335
p03776
u076936237
1491004814
Python
Python (3.4.3)
py
Runtime Error
94
6092
1047
import statistics as stats from math import factorial class Comb: def __init__(self): super(Comb, self).__init__() self.dic = {} def nCr(self, n, r): if n == r or r == 0: return 1 if self.dic.get((n, r), None) is None: self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r) return self.dic[(n,r)] def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] max_ = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_bmin_cnt = v_list.count(bucket_min) b_bmin_cnt = max_bucket.count(bucket_min) all_max_cnt = v_list.count(max_) comb = Comb() print(max_ave) if all_max_cnt <= A: print(comb.nCr(all_bmin_cnt, b_bmin_cnt)) else: num = 0 for r in range(A, B+1): num += comb.nCr(all_max_cnt, r) print(num) if __name__ == '__main__': main()
s285080519
p03776
u076936237
1491000268
Python
Python (3.4.3)
py
Runtime Error
53
5788
814
import statistics as stats from math import factorial def nCr(n, r): return int(factorial(n)/factorial(n-r)/factorial(r)) def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] bucket_max = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_num = v_list.count(bucket_min) bucket_num = max_bucket.count(bucket_min) print(max_ave) if bucket_min == bucket_max: if all_num >= B: print(2**B-1) else: num = 0 for i in range(A, B+1): num += nCr(all_num, i) print(num) else: print(nCr(all_num, bucket_num)) if __name__ == '__main__': main()
s064797276
p03776
u076936237
1491000082
Python
Python (3.4.3)
py
Runtime Error
44
5532
783
import statistics as stats from math import factorial def nCr(n, r): return int(factorial(n)/factorial(n-r)/factorial(r)) def main(): N, A, B = tuple(map(int, input().split(' '))) max_ave = 0 v_list = sorted(list(map(int, input().split(' '))), reverse=True) bucket_min = v_list[A-1] bucket_max = v_list[0] max_bucket = v_list[:A] max_ave = stats.mean(max_bucket) all_num = v_list.count(bucket_min) bucket_num = max_bucket.count(bucket_min) print(max_ave) if bucket_min == bucket_max: if all_num >= B: print(2**B-1) else: num = sum([nCr(all_num, r) for r in range(A, B+1)]) print(num) else: print(nCr(all_num, bucket_num)) if __name__ == '__main__': main()
s956598167
p03776
u004797437
1490909738
Python
Python (3.4.3)
py
Runtime Error
17
3064
443
n, a, b = [int(i) for i in input().split(" ")] v = [int(i) for i in input().split(" ")] v.sort(reverse=True) res = sum(v[:a])/a print("{0:.6f}".format(res)) if not v[0]==v[a-1]: x = v[:a].count(v[a-1]) y = v.count(v[a-1]) print(int(math.factorial(y)/math.factorial(x)/math.factorial(y-x))) else: comb = 0 for i in range(a, b+1): comb += math.factorial(n)/math.factorial(i)/math.factorial(n-i) print(int(comb))
s535781137
p03776
u813098295
1490853686
Python
Python (2.7.6)
py
Runtime Error
13
2816
575
from math import factorial N, A, B = map(int, raw_input().split()) v = map(int, raw_input().split()) C = [[0 for i in range(51)] for j in range(51)] #C[n][k] => nCk for i in range(1, N+1): for j in rane(1, i+1): if (j == 0 or j == i): C[i][j] = 1 else: C[i][j] = C[i-1][j-1] + C[i-1][j] v.sort(reverse = True) t = v[A-1] ans = 0 X, Y = v.count(t), v[:A].count(t) if (v[0] != v[A-1]): ans = C[X][Y] else: for i in range(A, B+1): if(i <= X): ans += comb[X][i] print float(sum(v[0:A]))/A print ans
s490775558
p03776
u075012704
1490798262
Python
Python (3.4.3)
py
Runtime Error
17
3064
1227
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[:A] ave = sum(S) / A print(ave) Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら i = A while i <= B and V[-i] == min(S): C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i)) i += 1 else: # 商品価値が均一でなかったのなら # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(C)
s370787943
p03776
u075012704
1490798129
Python
Python (3.4.3)
py
Runtime Error
17
3064
1239
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A+1] ave = sum(S) / A print(S) print(ave) Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら i = A while i <= B and V[-i] == min(S): C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i)) i += 1 else: # 商品価値が均一でなかったのなら # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(C)
s714547190
p03776
u075012704
1490797757
Python
Python (3.4.3)
py
Runtime Error
18
3064
896
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) Vs = V.count(min(S)) Ss = S.count(min(S)) if min(S) != max(S): C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss)) print(C) else: i = A C = 0 while i <= B and V[-i] == min(S): c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i)) C = C + c i = i + 1 print(C)
s965970276
p03776
u075012704
1490797643
Python
Python (3.4.3)
py
Runtime Error
17
3064
901
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(S) print(ave) Vs = V.count(min(S)) Ss = S.count(min(S)) if min(S) != max(S): C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss)) print(C) else: i = A C = 0 while i <= B and V[-i] == min(S): c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i)) C = C + c i = i + 1 print(C)
s063819760
p03776
u075012704
1490797094
Python
Python (3.4.3)
py
Runtime Error
18
3064
1228
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら i = A while i <= B and V[-i] == min(S): C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i)) i += 1 else: # 商品価値が均一でなかったのなら # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(C)
s312508097
p03776
u123756661
1490736835
Python
PyPy2 (5.6.0)
py
Runtime Error
47
32364
680
def pscl(num,l=[1]): for i in range(num): l = map(lambda x,y:x+y,[0]+l,l+[0]) return l n,a,b=map(int,raw_input().split()) v=[int(i) for i in raw_input().split()] chk=[i for i in set(v)] chk.sort() if len(chk)==1: print chk[0]*1.0 print sum(pscl(n)[a:b+1]) exit() d={} for i in v: if i in d: d[i]+=1 else: d[i]=1 total=ans=tmp=0 t=a for i in chk[::-1]: if d[i]<t: total=total+i*d[i] t=t-d[i] else: total=total+i*t print total*1.0/a # print d,t,d[i],b-(a-t),pscl(d[i]) #print sum(pscl(d[i])[t:min(d[i],b-(a-t))+[0,1][d[i]>b-(a-t)]]) print pscl(d[i][t]) break
s954568128
p03776
u075012704
1490727262
Python
Python (3.4.3)
py
Runtime Error
18
3064
1236
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら i = A while i <= B and V[-i] == min(S): C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i)) i += 1 else: # 商品価値が均一でなかったのなら # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(C)
s351639092
p03776
u075012704
1490727094
Python
Python (3.4.3)
py
Runtime Error
17
3064
1498
''' Created on 2017/03/26 @author: Tomoya ''' import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # cnt:カウンター cnt = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら for i in range(N): # N個の商品の中に最大価値値を持つものがいくつあるか調べる if V[0] == V[i]: cnt += 1 j = A while j <= B and V[-i] == min(S): C = C + math.factorial(Vs) / ( math.factorial(Vs - i) * math.factorial(i)) j += 1 else: # 商品価値が均一でなかったのなら # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(int(C))
s124173336
p03776
u075012704
1490726968
Python
Python (3.4.3)
py
Runtime Error
18
3064
1443
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # cnt:カウンター cnt = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら for i in range(N): # N個の商品の中に最大価値値を持つものがいくつあるか調べる if V[0] == V[i]: cnt += 1 j = A while j <= B and V[-i] == min(S): C = C + math.factorial(cnt) / ( math.factorial(cnt - i) * math.factorial(i)) j += 1 else: # 商品価値が均一でなかったのなら Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(C)
s736575606
p03776
u075012704
1490726910
Python
Python (3.4.3)
py
Runtime Error
18
3188
1448
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # cnt:カウンター cnt = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら for i in range(N): # N個の商品の中に最大価値値を持つものがいくつあるか調べる if V[0] == V[i]: cnt += 1 j = A while j <= B and V[-i] == min(S): C = C + math.factorial(cnt) / ( math.factorial(cnt - i) * math.factorial(i)) j += 1 else: # 商品価値が均一でなかったのなら Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(int(C))
s948518229
p03776
u075012704
1490726715
Python
Python (3.4.3)
py
Runtime Error
17
3064
1467
import math # D - Maximum Average Sets # 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d # N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # cnt:カウンター cnt = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら for i in range(N): # N個の商品の中に最大価値値を持つものがいくつあるか調べる if V[0] == V[i]: cnt += 1 for i in range(A,B+1): if V[-i] == min(S): break C = C + math.factorial(cnt) / ( math.factorial(cnt - i) * math.factorial(i)) else: # 商品価値が均一でなかったのなら Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(int(C))
s523802095
p03776
u075012704
1490726563
Python
Python (3.4.3)
py
Runtime Error
18
3064
1311
# N:商品の数 A個以上B個以下の範囲で選ぶ N, A, B = map(int, input().split()) # C:最大価値組み合わせ総数 C = 0 # cnt:カウンター cnt = 0 # 商品価値をリストに入れる V = [int(value) for value in input().split()] # 商品価値が高い順に並び替え V.sort(reverse=True) # 商品価値が高いものから出来るだけ少なく(=A個)選ぶのが最も平均価値が高くなる S = V[0:A] ave = sum(S) / A print(ave) if V[0]== V[A-1]: # もしもA個選んだ中の商品価値が全て同じだったら for i in range(N): # N個の商品の中に最大価値値を持つものがいくつあるか調べる if V[0] == V[i]: cnt += 1 for i in range(A,B+1): C = C + math.factorial(cnt) / ( math.factorial(cnt - i) * math.factorial(i)) else: # 商品価値が均一でなかったのなら Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか # nCk = n! /( (n-k)! * k! )に基づきCを計算 C = math.factorial(Vs) / (math.factorial(Vs - Ss) * math.factorial(Ss) ) print(int(C))
s057149976
p03776
u209647862
1490676395
Python
Python (3.4.3)
py
Runtime Error
18
3064
669
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import factorial def comb(n, r): nf = factorial(n) rf = factorial(r) nrf = factorial(n - r) return int(nf / (rf * nrf)) n, a, b = map(int, input().split()) goods = list(reversed(sorted([int(x) for x in input().split()]))) avg, total = sum(goods[:a]) / a, 0 lastcount, lastindex = 0, 0 for i, val in enumerate(goods): if val == goods[a - 1]: lastcount += 1 if i < a: lastindex += 1 if a == 1 or goods[0] != goods[a - 1]: total += comb(lastcount, lastindex) else: for i in range(a, b + 1): total += comb(lastcount, i) print(avg) print(total)
s569571267
p03776
u209647862
1490675948
Python
Python (3.4.3)
py
Runtime Error
18
3064
659
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import factorial def comb(n, r): nf = factorial(n) rf = factorial(r) nrf = factorial(n - r) return int(nf / (rf * nrf)) n, a, b = map(int, input().split()) goods = list(reversed(sorted([int(x) for x in input().split()]))) avg, total = sum(goods[:a]) / a, 0 lastcount, lastindex = 0, 0 for i, val in enumerate(goods): if val == goods[a - 1]: lastcount += 1 if i < a: lastindex += 1 if goods[0] != goods[a - 1]: total += comb(lastcount, lastindex) else: for i in range(a, b + 1): total += comb(lastcount, i) print(avg) print(total)
s923750539
p03776
u209647862
1490675688
Python
Python (3.4.3)
py
Runtime Error
18
3064
659
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import factorial def comb(n, r): nf = factorial(n) rf = factorial(r) nrf = factorial(n - r) return int(nf / (rf * nrf)) n, a, b = map(int, input().split()) goods = list(reversed(sorted([int(x) for x in input().split()]))) avg, total = sum(goods[:a]) / a, 0 lastcount, lastindex = 0, 0 for i, val in enumerate(goods): if val == goods[a - 1]: lastcount += 1 if i < a: lastindex += 1 if goods[0] != goods[a - 1]: total += comb(lastcount, lastindex) else: for i in range(a, b + 1): total += comb(lastcount, i) print(avg) print(total)
s932439508
p03776
u209647862
1490675595
Python
Python (3.4.3)
py
Runtime Error
21
3316
759
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import factorial from collections import defaultdict def comb(n, r): nf = factorial(n) rf = factorial(r) nrf = factorial(n - r) return int(nf / (rf * nrf)) n, a, b = map(int, input().split()) goods = list(reversed(sorted([int(x) for x in input().split()]))) counter = defaultdict(int) for v in goods: counter[v] += 1 avg, total = sum(goods[:a]) / a, 0 lastcount, lastindex = 0, 0 for i, val in enumerate(goods): if val == goods[a - 1]: lastcount += 1 if i < a: lastindex += 1 if goods[0] != goods[a - 1]: total += comb(lastcount, lastindex) else: for i in range(a, b + 1): total += comb(lastcount, i) print(avg) print(total)
s605658860
p03776
u124139453
1490640435
Python
Python (2.7.6)
py
Runtime Error
11
2692
416
import itertools,math,bisect,pprint,sys n, a, b = map(int, raw_input().split()) v = sorted(map(int, raw_input().split()))[::-1] res1 = sum(v[:a])*1.0/a print res1 res2 = 0 def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) if a==v[:a].count(v[a-1]): res2 = 0 for i in range(a,b+1): res2 += nCr(v.count(v[a]),i) print res2 else: print nCr(v.count(v[a-1]),v[:a].count(v[a-1]))
s650931171
p03776
u124139453
1490640153
Python
Python (2.7.6)
py
Runtime Error
12
2692
410
import itertools,math,bisect,pprint,sys n, a, b = map(int, raw_input().split()) v = sorted(map(int, raw_input().split()))[::-1] res1 = sum(v[:a])*1.0/a print res1 res2 = 0 def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) if a==v[:a].count(v[a]): res2 = 0 for i in range(a,b+1): res2 += nCr(v.count(v[a]),i) print res2 else: print nCr(v.count(v[a]),v[:a].count(v[a]))
s032150990
p03776
u124139453
1490639902
Python
Python (2.7.6)
py
Runtime Error
12
2820
393
import itertools,math,bisect,pprint,sys n, a, b = map(int, raw_input().split()) v = sorted(map(int, raw_input().split()))[::-1] res1 = sum(v[:a])*1.0/a print res1 res2 = 0 def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) if a==v[:a].count(v[a]): res2 = 0 for i in range(a,b): res2 += nCr(v.count(v[i]),i) else: print nCr(v.count(v[a]),v[:a].count(v[a]))
s015095425
p03776
u177726873
1490582380
Python
Python (2.7.6)
py
Runtime Error
10
2568
478
# -*- coding: utf-8 -*- # get two integers separated with half-width break N, A, B = map(int, raw_input().split()) v = [] combos = [] for i in range(N): v.append(int(raw_input())) def permute(v, L): p = [] for l in L: p += [l.append(i) for i in v] return p ll = [] for i in range(B): ll = permute(v, ll) if i + 1 >= A: combos += ll averages = [sum(j)/len(j) for j in combos] print(max(averages)) print(averages.count(max(averages)))
s322014539
p03776
u476383383
1490582307
Python
Python (3.4.3)
py
Runtime Error
2216
1808164
600
from itertools import combinations N,A,B = [int(i) for i in input().split()] v = [int(i) for i in input().split()] v.sort() if v[-A] != v[-A-1]: print(sum(v[-A:]) / A) print(1) elif v[-1] : # AAと同じ数のカウント # Aよりも大きい数のカウント cnt = 0 bigger = 0 for i in range(N): if v[A] < v[i]: bigger += 1 if v[i] == v[A]: cnt += 1 ans = 0 mini = min(B, cnt+bigger) for i in range(A,mini): ans += len(list(combinations(range(cnt), i - bigger))) print(sum(v[-A:]) / A) print(ans)