当前位置:网站首页>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')
总结
纯分析找规律
边栏推荐
猜你喜欢
面试官:可以谈谈乐观锁和悲观锁吗

CWE4.8:2022年危害最大的25种软件安全问题

cpolar应用实例之多设备数据采集

开源一夏 |【云原生】DevOps(五):集成Harbor

小程序毕设作品之微信体育馆预约小程序毕业设计成品(8)毕业设计论文模板

“12306”的架构到底有多牛逼?

C#里如何简单的校验时间格式

Data Governance: The Evolution of Data Integration and Application Patterns

Google Earth Engine APP—— 一个不用写代码可以直接下载相应区域的1984-2021年的GIF遥感影像动态图

织梦自定义表单添加全选和全不选功能按钮
随机推荐
Flink学习9:配置idea开发flink-Scala程序环境
ES: WeakSet
redis总结_基础
Google Earth Engine APP—— 一个不用写代码可以直接下载相应区域的1984-2021年的GIF遥感影像动态图
成功部署工业物联网的五个关键
天翼云4.0分布式云赋能千行百业数字化转型
What is the difference between erp system and wms system
Flink Learning 9: Configure the idea to develop the flink-Scala program environment
54.【system系统互动函数大总结】
golang刷leetcode 经典(5)设计哈希集合
LiveGBS国标GB/T28181流媒体平台支持主子码流切换主码流stream/streamprofile
技术人生 | 如何设定业务目标
我的递归从不爆栈
Security First: Tools You Need to Know to Implement DevSecOps Best Practices
LeetCode 2336. 无限集中的最小数字(SortedSet)
小程序毕设作品之微信体育馆预约小程序毕业设计成品(7)中期检查报告
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx
HDF驱动框架的API(1)
本地MSE播放fragment mp4服务
无法超越的100米_百兆以太网传输距离_网线有哪几种?