Skip to content

Commit 24b2ecd

Browse files
Added Codechef Problem
1 parent 5aa3542 commit 24b2ecd

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
t = int(input())
2+
year = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0]
3+
4+
for _ in range(t):
5+
m1,y1 = map(int,input().split())
6+
m2,y2 = map(int,input().split())
7+
if(m1<=2):
8+
y1-=1
9+
if(m2<2):
10+
y2-=1
11+
value1 = (y1//400)*101 + sum(year[:y1%400])
12+
value2 = (y2//400)*101 + sum(year[:y2%400])
13+
print(value2 - value1)

CodeChef_problems/expected_change.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def fun(s):
2+
ans = 0
3+
o = 0
4+
c = 0
5+
for i in s:
6+
if(i=="("):
7+
o+=1
8+
elif(i==")"):
9+
c+=1
10+
if(c>o):
11+
c-=1
12+
o+=1
13+
ans+=1
14+
return ans
15+
16+
t = int(input())
17+
18+
for _ in range(t):
19+
n = int(input())
20+
s = input()
21+
ans = 0
22+
N = 10**9+7
23+
value = ((n+1)*n)//2
24+
value = pow(value,N-2,N)
25+
print(value)
26+
for i in range(n):
27+
ans+=fun(s[i:])
28+
print((ans*value)%N)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# def fun(mymatrix,col,row,xvalue):
2+
# ans = 0
3+
# maximum = 0
4+
# #itration 1
5+
# for i in range(4):
6+
# if(row[i]==1):
7+
# for j in range(4):
8+
# if(col[j]==1):
9+
# if(mymatrix[i][j]>maximum):
10+
# maximum = mymatrix[i][j]
11+
# if(maximum==0):
12+
# ans-=(5-xvalue)*100
13+
# return ans
14+
# ans+=maximum*(5*xvalue)*25
15+
# value = []
16+
# for i in range(4):
17+
# flag = 0
18+
# if(row[i]==1):
19+
# for j in range(4):
20+
# if(col[j]==1):
21+
# if(mymatrix[i][j]==maximum):
22+
# col[j] = 0
23+
# row[i] = 0
24+
# value.append(fun(mymatrix,col,row,xvalue+1))
25+
# col[j] = 1
26+
# row[i] = 1
27+
28+
# return ans + max(value)
29+
30+
t = int(input())
31+
myans = 0
32+
for _ in range(t):
33+
n = int(input())
34+
# col = [1 for i in range(4)]
35+
# row = [1 for i in range(4)]
36+
mymatrix = [[0 for i in range(4)] for i in range(4)]
37+
for i in range(n):
38+
[a,b] = input().split()
39+
if(a=='A'):
40+
mymatrix[0][(int(b)//3)%4]+=1
41+
elif(a=='B'):
42+
mymatrix[1][(int(b)//3)%4]+=1
43+
elif(a=='C'):
44+
mymatrix[2][(int(b)//3)%4]+=1
45+
else:
46+
mymatrix[3][(int(b)//3)%4]+=1
47+
value = []
48+
for a in range(4):
49+
for b in range(4):
50+
for c in range(4):
51+
for d in range(4):
52+
if(a!=b and a!=c and a!=d and b!=c and b!=d and c!=d):
53+
mylist = [mymatrix[0][a],mymatrix[1][b],mymatrix[2][c],mymatrix[3][d]]
54+
mylist.sort()
55+
if(mylist[0]!=0):
56+
value.append(mylist[0]*25 + mylist[1]*50 + mylist[2]*75 + mylist[3]*100)
57+
elif(mylist[1]!=0):
58+
value.append(mylist[3]*100 + mylist[1]*50 + mylist[2]*75 -100)
59+
elif(mylist[2]!=0):
60+
value.append(mylist[2]*75 + mylist[3]*100 -200)
61+
elif(mylist[3]!=0):
62+
value.append(mylist[3]*100 - 300)
63+
else:
64+
value.append(-400)
65+
66+
value = max(value)
67+
myans += value
68+
print(value)
69+
print(myans)
70+
71+
72+

0 commit comments

Comments
 (0)