当前位置:网站首页>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')
总结
纯分析找规律
边栏推荐
- The days of patching are more difficult than the days of writing code
- 有关代购系统搭建的那点事
- golang刷leetcode 经典(2)拓扑排序
- Mini Program Graduation Works WeChat Gymnasium Reservation Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
- ffmpeg cannot find libx264 after compilation
- 详细教学——1688关键词搜索API操作流程
- 如何应对机器身份带来的安全风险
- 数据治理:数据集成和应用模式的演进
- 2021年下半年软件设计师上午真题
- POE交换机全方位解读(下)
猜你喜欢

织梦自定义表单添加全选和全不选功能按钮

详细教学——1688关键词搜索API操作流程

小程序毕设作品之微信体育馆预约小程序毕业设计成品(6)开题答辩PPT

Go 语言快速入门指南:第二篇 变量与常量

LeetCode 2333. 最小差值平方和(贪心)

Gear 月度更新|6 月

深圳地铁16号线二期进入盾构施工阶段,首台盾构机顺利始发

嵌入式Qt-做一个秒表

Mini Program Graduation Works WeChat Gymnasium Reservation Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template

mui中使用多级选择器实现省市区联动
随机推荐
redis总结_分布式缓存
LeetCode 2333. 最小差值平方和(贪心)
Remember the stuck analysis of an industrial automation control system in .NET
小程序毕设作品之微信体育馆预约小程序毕业设计成品(5)任务书
安全至上:落地DevSecOps最佳实践你不得不知道的工具
golang刷leetcode滑动窗口(9) 颜色分类
How to ensure the security of smart factories?
Wechat Gymnasium Appointment Mini Program Graduation Design Finished Works Mini Program Graduation Design Finished Work (6) Question Opening Reply PPT
百问百答第49期:极客有约——国内可观测领域SaaS产品的发展前景
小程序毕设作品之微信体育馆预约小程序毕业设计成品(7)中期检查报告
MySQL索引
DevOps之代码检查
基于HDF的LED驱动程序开发(1)
究极异常处理逻辑——多层次异常的处理顺序
MySQL表的约束
危及安全的常见物联网攻击有哪些?
golang刷leetcode 经典(3) 设计推特
千万级QPS下服务如何才能平滑启动
LiveGBS国标GB/T28181流媒体平台支持主子码流切换主码流stream/streamprofile
LeetCode 1947. 最大兼容性评分和(状态枚举DP)