1.
n=int(input())
mn=[]
for i in range(n):
aa=[]
for j in range(2):
line=int(input())
aa.append(line)
mn.append(aa)
def Last(n, m):
if not n or not m:
return -1
lst = [i+1 for i in range(n)]
i = 0
res=[]
while len(lst)>1:
i = (m+i-1)%len(lst)
k=lst.pop(i)
res.append(k)
res.append(lst[0])
return res
for i in range(n):
nn=mn[i][0]
mm=mn[i][1]
ww=Last(nn, mm)
# print(ww)
for j in ww[:-1]:
print(j,end=' ')
print(ww[-1])
2.
a, b = 10,10
lst = list(map(int, input().split(' ')))
bb = []
for i in range(a):
line = lst[10*(i):10*(i+1)]
bb.append(line)
class Solution:
def __init__(self, pos):
self.pos = pos
self.cnt = 0
self.dp = []
def dfs(self, i, j):
if 0 <= i < a and 0 <= j < b:
if self.pos[i][j] == 1:
self.cnt += 1
self.pos[i][j] = 0
self.dfs(i - 1, j)
self.dfs(i + 1, j)
self.dfs(i, j - 1)
self.dfs(i, j + 1)
def func(self):
for i in range(a):
for j in range(b):
if self.pos[i][j] == 1:
self.cnt = 0
self.dfs(i, j)
if self.cnt > 0:
self.dp.append(self.cnt)
return max(self.dp)
s = Solution(bb)
m = s.func()
print(m)
3.
n = int(input().strip())
aa = [int(x) for x in input().strip().split()]
def huiwenxulie(aa, l, r):
t=0
left = aa[l]
right = aa[r]
while (l<r):
if left<right:
l+=1
left+=aa[l]
t+=1
continue
elif left>right:
r-=1
right+=aa[r]
t+=1
continue
elif left==right:
l+=1
r-=1
left = aa[l]
right = aa[r]
return t
print (huiwenxulie(aa,0,n-1))