当前位置:网站首页>codeforces:E. Add Modulo 10【状态压缩 + 找规律】
codeforces:E. Add Modulo 10【状态压缩 + 找规律】
2022-08-02 17:49:00 【白速龙王的回眸】

分析
分类讨论,进行操作
【5,0】落回0
其余落到2
然后就停止
分两类
如果是第一类,必须是同一个0结尾才行
如果第二类,必须%20相同才行
ac code
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
# [5, 0] => 0
# others => 2
check0 = 0
for i in range(len(a)):
while a[i] % 10 != 0 and a[i] % 10 != 2:
a[i] += a[i] % 10
#print(a[i])
if a[i] % 10 == 0:
check0 = 1
if check0:
if len(set(a)) > 1:
print('NO')
else:
print('YES')
continue
# without 0
val = a[0] % 20
flag = True
for aa in a:
if aa % 20 != val:
flag = False
break
if flag:
print('YES')
else:
print('NO')
总结
纯分析找规律
边栏推荐
猜你喜欢
随机推荐
Redis总结_实战篇
租房小程序自动定位城市
面试官:可以谈谈乐观锁和悲观锁吗
ES: export 的用法
KunlunBase 1.0 is released!
开源一夏 |【云原生】DevOps(五):集成Harbor
9月起中国给予多哥等16国98%税目产品零关税待遇
魔豹联盟:佛萨奇2.0dapp系统开发模式详情
影响PoE供电传输距离的除了网线还有啥?
cache2go-源码阅读
golang刷leetcode 经典(4) 实现跳表
golang源码分析(19)简单编译器-计算器
基于HDF的LED驱动程序开发(1)
Taking advantage of cloud-network integration, e-Surfing Cloud has paved the way for digital transformation for government and enterprises
在线文档Sheet技术解析
无法超越的100米_百兆以太网传输距离_网线有哪几种?
故障分析 | 一条 SELECT 语句跑崩了 MySQL ,怎么回事?
Interviewer: can you talk about optimistic locking and pessimistic locks
golang刷leetcode动态规划(9)不同路径 II
今年上半年,我国公路建设总体形势持续向好









