酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

给定一个多项式 ( � � + � � ) � (ax+by) k ,请求出多项式展开后 � � ∗ � � x n ∗y m 项的系数。 input format 共一行,包含 5 5 个整数,分别为 � , � , � , � , � a,b,k,n,m,每两个整数之间用一个空格隔开。 output format 输出共 1 1 行,包含一个整数,表示所求的系数,这个系数可能很大, 输出对 10007 10007 取模后的结果。 输入数据 1 1 1 3 1 2 输出数据 1 3

```python a, b, k, n, m = map(int, input().split()) # calculates binomial coefficient def binomial_coefficient(n, m): res = 1 for i in range(m): res = res * (n - i) // (i + 1) return res # calculates coefficient of x^n * y^m term coefficient = binomial_coefficient(k, n) * an * bm % 10007 print(coefficient) ``` [2024-12-05 20:31:25 | AI写代码神器 | 228点数解答]

相关提问