1.
while True:
try:
n=eval(input())
a=1 #分母
f=1 #表示加减符号
m=0 #前n项和
r=0 #表示每一项的值
for i in range(1,n+1):
r=1.0/a
m=m+f*r
f= -1*f
a+=2
print("{:.5f}".format(m))
except:
break
2.
n=eval(input())
ans=0
while n!=1:
if n%2==0:
n=n//2 # //:在py中表示整除 和java中的/作用一样
else:
n=n*3+1
ans+=1
print(ans)
3.
n=eval(input())
s1=input()
s2=input()
cnt=0 #cnt存储答案
for i in range(len(s1)):
if s1[i]==s2[i]:
cnt+=1
else :
break
n-=2
for o in range(n):
s=input()
for i in range(0,cnt):
if s[i]!=s1[i]:
cnt-=1
print(cnt)
4.
int jos(int n)
{
int y=1;
for(int i=1;i<=n;i++)
{
y=(y+7)%i;
}
return y+1;
}
5.
cnt=eval(input())
for i in range(cnt):
n,m=map(int,input().split())
huahua=[] #存储花花的上线时间
diaodiao=[] #存储diaodiao的上线时间
for j in range(n):
a,b=map(int,input().split())
for x in range(a,b+1): # 实际范围 a<= x <=b
if x not in huahua:
huahua.append(x)
for j in range(m):
a, b = map(int, input().split())
for x in range(a, b + 1): #同上
if x not in diaodiao:
diaodiao.append(x)
ans=0
for x in huahua:
if x in diaodiao:
ans+=1
continue
print(ans)
6.
while True:
try:
n, m, x, y, t = map(int, input().split())
if n == 0 and m == 0 and x == 0 and y == 0 and t == 0:
break
q = eval(input())
now = 0 # 表示当前时间
all = [] # 记录在t秒前的所有操作
for i in range(q):
dir, time = map(int, input().split())
if time >= t:
continue
a = {'dir': dir, 'time': time}
all.append(a)
# all.sort(key=lambda x:x['time']) #按照时间先后进行排序 可以不排序 题目保证time递增
direct = 3 # 默认向右
for i in range(0, t): # 遍历 0 - t-1
for j in all:
if j['time'] == i:
direct = j['dir']
break
if direct == 0: # 向上
x -= 1
if x == -1: # 走到边界了
x = n - 1
elif direct == 1: # 向下
x += 1
if x == n:
x = 0
elif direct == 2: # 向左
y -= 1
if y == -1:
y = m - 1 #注意改成m 这个点卡了我20分钟。。。。
elif direct == 3: # 向右
y += 1
if y == m: #注意改成m
y = 0
print(f"{x} {y}")
except:
break