当前位置:网站首页>E. Add Modulo 10(规律)
E. Add Modulo 10(规律)
2022-08-02 18:41:00 【Harris-H】
E. Add Modulo 10(规律)
可以看出末位为1、3、6、7、9 最终会进入到2、4、8、6的循环。
2 + 4 + 8 + 6 = 20 2+4+8+6=20 2+4+8+6=20,这个周期的长度为20。
对于末位 5 , 0 5,0 5,0 最终会变成末位为0。
因此分两种情况: 0 、 2 0、2 0、2。
先把第一种情况末位变成为2,然后模20,第二种情况就变成末位为0,不取模。
然后比较 n n n个数是否相同。
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t; cin >> t;
while(t--)
{
int n; cin >> n;
vector<int> a(n);
// 2 0
for (int i = 0; i < n; i++) {
cin >> a[i];
while(a[i]%10 != 2 && a[i]%10 != 0) {
a[i] += a[i]%10;
}
if(a[i]%10 == 2) {
a[i] %= 20;
}
}
cout << (a == vector(n, a[0]) ? "Yes\n":"No\n");
}
return 0;
}
边栏推荐
- Win11dll文件缺失怎么修复?Win11系统dll文件丢失的解决方法
- 7.22 - 每日一题 - 408
- ETH Zurich重磅综述 | 人脸-素描合成:一个新的挑战
- 【动态规划专项训练】基础篇
- What is the use of IT assets management software
- 请教一个数据库连接池的问题,目前已知是事务未设置超时,又有一块代码事务没有提交,一直把连接给耗尽了,
- 7.23 - 每日一题 - 408
- How can services start smoothly under tens of millions of QPS
- 7.24 - 每日一题 - 408
- Unity 打包和切换平台|Build Settings窗口介绍
猜你喜欢

selenium installation and environment configuration firefox

如何正确地配置入口文件?

codeforces:E. Add Modulo 10【状态压缩 + 找规律】

荐号 | 当一个人不联系你,不拉黑你,原因只有一个……!

研发了 5 年的时序数据库,到底要解决什么问题?

Monitor is easy to Mars debut: distributed operations help TOP3000 across management gap

【C语言刷题】牛客网刷题——替换空格

Detailed explanation of AtomicInteger

通信大学生走向岗位,哪些技能最实用?

读书笔记之《你想过怎样的一生?》
随机推荐
Boyun Selected as Gartner China DevOps Representative Vendor
How to mitigate the attack of corporate account hijacking?
Endanger the safety of common Internet attacks have?
手机银行体验性测试:如何获取用户真实感受
下载mysql的源码包
Jupyter Notebook(Anaconda)——两个环境分别修改默认打开目录(深度学习第一周番外篇)
What skills are the most practical for college students in communications?
情景剧《重走长征路》上演
实例034:调用函数
LeetCode 2349. 设计数字容器系统(SortedSet)
说一件事
MySQL LIKE – 语法和用法示例教程
洛谷P1502 窗口的星星
如何正确地配置入口文件?
AtomicInteger详解
2022最新彩虹表
3年半测试经验,20K我都没有,看来是时候跳槽了
指针常量和常量指针概述
知识点滴 - 什么是iAP2 (上)
如何获取EasyCVR平台设备通道的RTMP视频流地址?