Acwing 第 47 场周赛

摘要
Title: Acwing 第 47 场周赛
Tag: 模拟

Powered by:NEFU AB-IN

Link

Acwing 第 47 场周赛

  • A AcWing 4399. 数字母

    • 思路

      除去, 和空格即可

    • 代码

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      from collections import Counter
      s = input()[1:-1]
      d = Counter(s)
      ans = 0
      if " " in d.keys():
      ans -= 1
      if "," in d.keys():
      ans -= 1

      print(len(d) + ans)
  • B AcWing 4400. 玩游戏

    • 思路

      手动模拟队列即可,注意就是当弹出后求下一个起点时,如果此时其位于队首,就不用减1

    • 代码

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      '''
      Author: NEFU AB-IN
      Date: 2022-04-16 18:57:57
      FilePath: \ACM\Acwing\47\b.py
      LastEditTime: 2022-04-16 19:27:29
      '''
      n, k = map(int, input().split())
      a = list(map(int, input().split()))
      q = [i for i in range(n)]

      s = 0
      for i in range(k):
      id = (s + a[i]) % len(q)
      s = (id + 1) % len(q)
      print(q[id] + 1, end=" ")
      q.pop(id)
      if s:
      s = (s - 1) % len(q)
  • C AcWing 4401. 找回数组

    • 思路

      求出差分数组,如果b[i]!=b[i+k]b[i] != b[i + k]说明kk不能取

    • 代码

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      '''
      Author: NEFU AB-IN
      Date: 2022-04-16 19:38:19
      FilePath: \ACM\Acwing\47\c.py
      LastEditTime: 2022-04-16 19:38:20
      '''
      n = int(input())
      a = [0, *list(map(int, input().split()))]

      b = [0] * 1100
      for i in range(1, n + 1):
      b[i] = a[i] - a[i - 1]
      ans = []
      for k in range(1, n + 1):
      flag = 0
      for i in range(1, n + 1):
      if i + k > n:
      break
      if b[i] != b[i + k]:
      flag = 1
      break
      if flag == 0:
      ans.append(k)
      print(len(ans))
      for i in ans:
      print(i, end=" ")
使用搜索:谷歌必应百度