前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >codeforces 911C (找规律)

codeforces 911C (找规律)

作者头像
dejavu1zz
发布2020-10-23 15:18:33
3050
发布2020-10-23 15:18:33
举报

题目描述

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

直接判断即可

代码

代码语言:javascript
复制
#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;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-06-21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 题目描述
  • 思路
  • 代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档