Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def gcd(a,b):
if a == 0:
return b
return gcd(b % a, a)

def lcm(a,b):
return (a / gcd(a,b))* b

t=int(input())
for i in range(t):
n,a,b,k = map(int, input().split())
totala = n//a
totalb = n//b
lcmab = int(lcm(a,b))
totallcm = n//lcmab
total = totala + totalb - 2*totallcm
if(total>=k):
print("Win")
else:
print("Lose")
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def MrRobot(string):
n = len(string)
if (n < 2):
return string
start=0
maxLength=1
for i in range(n):
low = i - 1
high = i + 1
while (high < n and string[high] == string[i] ):
high=high+1
while (low >= 0 and string[low] == string[i] ):
low=low-1
while (low >= 0 and high < n and string[low] == string[high]):
low=low-1
high=high+1
length = high - low - 1
if (maxLength < length):
maxLength = length
start=low+1
return string[start:start + maxLength]

inp=input()
ct=0
ans=""
while(1):
inp=MrRobot(inp)
if(len(inp)==1):
ans=str(ct)+" "+inp
break
if(len(inp)%2==1):
inp=inp[:len(inp)-1]
else:
inp=inp[:len(inp)//2]
ct+=1

print(ans)