forked from swapnanildutta/Python-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpapergenarate1.py
More file actions
64 lines (62 loc) · 995 Bytes
/
papergenarate1.py
File metadata and controls
64 lines (62 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 15 09:48:18 2019
@author: SWANMOY
"""
def fact(n):
if n==0:
return 1
else:
return n*fact(n-1)
def combi(n, r):
g=fact(n)/(fact(n-r)*fact(r))
return g
x, s, y, m, z, c=input().split()
x=int(x)
s=int(s)
y=int(y)
m=int(m)
z=int(z)
c=int(c)
ch1, ch2=input().split()
ch3=input()
c1=ord(ch1)-64
c2=ord(ch2)-64
c3=ord(ch3)-64
result1=combi(x, s)*combi(y, m)*combi(z, c)
print(result1)
x1=x
y1=y
z1=z
s1=s
m1=m
c4=c
u2=x+y
if c3>=1 and c3<=x:
x1-=1
elif c3>x and c3<=u2:
y1-=1
else:
z1-=1
result2=combi(x1, s1)*combi(y1, m1)*combi(z1, c4)
if c1>=1 and c1<=x:
x1-=1
s1-=1
elif c1>x and c1<=u2:
y1-=1
m1-=1
else:
z1-=1
c4-=1
if c2>=1 and c2<=x:
x1-=1
s1-=1
elif c2>x and c2<=u2:
y1-=1
m1-=1
else:
z1-=1
c4-=1
result3=combi(x1, s1)*combi(y1, m1)*combi(z1, c4)
result4=result2-result3+1
print(result4)