codeforces 911C (找规律)
题目描述
Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on.
When a garland is switched on, it periodically changes its state — sometimes it is lit, sometimes not. Formally, if i-th garland is switched on during x-th second, then it is lit only during seconds x, x + ki, x + 2ki, x + 3ki and so on.
Mishka wants to switch on the garlands in such a way that during each second after switching the garlands on there would be at least one lit garland. Formally, Mishka wants to choose three integers x1, x2 and x3 (not necessarily distinct) so that he will switch on the first garland during x1-th second, the second one — during x2-th second, and the third one — during x3-th second, respectively, and during each second starting from max(x1, x2, x3) at least one garland will be lit.
Help Mishka by telling him if it is possible to do this!
思路
通过找规律发现,只有一下几种情况时才成立
1 X X 2 2 X 3 3 3 4 4 2
直接判断即可
代码
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef pair<char,char> PCC;
typedef long long LL;
const int N=5005;
const int M=150;
const int INF=0x3f3f3f3f;
const int MOD=998244353;
int cnt[N];
void solve(){
int k1,k2,k3;cin>>k1>>k2>>k3;
cnt[k1]++;
cnt[k2]++;
cnt[k3]++;
if(cnt[1]>=1) cout<<"YES"<<endl;
else if(cnt[2]>=2) cout<<"YES"<<endl;
else if(cnt[3]>=3) cout<<"YES"<<endl;
else if(cnt[4]==2 && cnt[2]==1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main(){
IOS;
solve();
return 0;
}
- Flask-SocketIO 文档译文
- 屏幕输出VS文件输出
- 判断一个数是不是2的幂
- (32) 剖析日期和时间 / 计算机程序的思维逻辑
- Python开发微信公众号后台(系列三)
- 【新手向】为何要这样安装Django?
- (33) Joda-Time / 计算机程序的思维逻辑
- Python实现守护进程
- 初探Anaconda——最省心的Python版本和第三方库管理
- Linux环境下JDK/Eclipse一键安装脚本
- (31) 剖析Arrays / 计算机程序的思维逻辑
- 应用自然语言处理(NLP)解码电影
- 不引入新的数组,实现数组元素交换位置函数
- (30) 剖析StringBuilder / 计算机程序的思维逻辑
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 为什么你画的Seurat包PCA图与别人的方向不一致?
- 用Python程序模拟300位观众,为5位嘉宾随机投票,最后按照降序排列结果
- Python知识点
- 上盘硬菜,@Transaction源码深度解析 | Spring系列第48篇
- Python--网络编程和并发
- HashMap常见问题(更新中)
- 使用SNVSniffer软件找somatic mutation
- 腾讯云cvm 内存使用率监控指标解读
- Redis常见面试题
- 使用MuSE软件找somatic mutation
- vivo 基于原生 RabbitMQ 的高可用架构实践
- 数据库锁
- 现在单细胞还想“水”CNS恐怕得多组学了
- 7个处理JavaScript值为undefined的技巧
- Python高级知识点