1.翻转

代码
输入数据,每组数据进行比较,j的范围掐头去尾,若a[j]==b[j],继续,若出现010,101子串则改成000,111,遍历完后比较a是否等于b,相同则输出次数,不同则输出-1。
            
            
              python
              
              
            
          
          for _ in range(int(input())):
    a = list(input())
    b = list(input())
    cnt = 0
    for j in range(1,len(a)-1):
        if a[j] == b[j]:
            continue
        elif b[j-1]==b[j+1] and b[j] != b[j-1]:
            b[j]=b[j-1]
            cnt += 1
    print(cnt if a==b else -1)2.取模

暴力:(只能通过90%)
            
            
              python
              
              
            
          
          def f(n,m)->bool:
    for y in range(1,m+1):
        for x in range(1,y):
            if n%x == n%y:
                return True
    return  False
t = int(input())
for _ in range(t):
    a,b = map(int,input().split())
    print('Yes' if f(a,b) else 'No')抽屉原理:
            
            
              python
              
              
            
          
          for _ in range(int(input())):
  chk=0
  n,m=map(int,input().split())
  for i in range(m,1,-1):
    if(n%i != (i-1)):
      chk=1
      break
  print("Yes") if chk else print("No")