题意与分析

极简单的数论+思维题。

代码

#include <bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (repType i = (a); i <= (b); ++i)
#define per(i, a, b) for (repType i = (a); i >= (b); --i)
#define QUICKIO \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
using ll=long long;
using repType=int; bool judge(int x)
{
if(x%8==0)
{
cout<<"YES"<<endl<<x<<endl;
return true;
}
return false;
} bool judge(int x,int y)
{
if(judge(x) || judge(y) || judge(x*10+y)) return true;
return false;
} int main()
{
string str; cin>>str;
if(str.length()<=2)
{
if(str.length()==1)
{
if((str[0]-'0')%8) cout<<"NO"<<endl;
else
{
cout<<"YES"<<endl<<str<<endl;
}
return 0;
}
else
{
if((str[0]-'0')%8==0)
{
cout<<"YES"<<endl<<str[0]<<endl;
return 0;
}
else if((str[1]-'0')%8==0)
{
cout<<"YES"<<endl<<str[1]<<endl;
return 0;
}
else if(((str[1]-'0')*10+str[0]-'0')%8==0)
{
cout<<"YES"<<endl<<str<<endl;
return 0;
}
cout<<"NO"<<endl;
return 0;
}
}
rep(i,0,str.length()-3)
{
int x=str[i]-'0';
if(judge(x)) return 0;
rep(j,i+1,str.length()-2)
{
int y=str[j]-'0';
if(judge(y) || judge(x,y)) return 0;
rep(k,j+1,str.length()-1)
{
int z=str[k]-'0';
if(judge(z) || judge(x,z) || judge(y,z)) return 0;
if(z%2) continue;
//cout<<x<<" "<<y<<" "<<z<<endl;
//cout<<(!(x%2))<<" "<<(y*10+z)%8<<((!(x%2)) && (y*10+z)%8==4)<<endl;
if((!(x%2) && (y*10+z)%8==0) || (x%2 && (y*10+z)%8==4))
{
cout<<"YES"<<endl;
//cout<<i<<" "<<j<<" "<<k<<endl;
rep(p,0,str.length()-1)
{
//cout<<"("<<p<<") ";
if(p<i || p==i || p==j || p==k) cout<<str[p];
}
cout<<endl;
return 0;
}
}
}
}
cout<<"NO"<<endl;
return 0;
}

「日常训练」Divisibility by Eight(Codeforces Round 306 Div.2 C)的更多相关文章

  1. 「日常训练」Regular Bridge(Codeforces Round 306 Div.2 D)

    题意与分析 图论基础+思维题. 代码 #include <bits/stdc++.h> #define MP make_pair #define PB emplace_back #defi ...

  2. 「日常训练」Two Substrings(Codeforces Round 306 Div.2 A)

    题意与分析 一道非常坑的水题.分析醒了补. 代码 #include <bits/stdc++.h> #define MP make_pair #define PB emplace_back ...

  3. 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)

    题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...

  4. 「日常训练」Alternative Thinking(Codeforces Round #334 Div.2 C)

    题意与分析 (CodeForces - 603A) 这题真的做的我头疼的不得了,各种构造样例去分析性质... 题意是这样的:给出01字符串.可以在这个字符串中选择一个起点和一个终点使得这个连续区间内所 ...

  5. 「日常训练」More Cowbell(Codeforces Round #334 Div.2 B)

    题意与分析(CodeForces 604B) 题意是这样的:\(n\)个数字,\(k\)个盒子,把\(n\)个数放入\(k\)个盒子中,每个盒子最多只能放两个数字,问盒子容量的最小值是多少(水题) 不 ...

  6. 「日常训练」Ice Cave(Codeforces Round 301 Div.2 C)

    题意与分析(CodeForces 540C) 这题坑惨了我....我和一道经典的bfs题混淆了,这题比那题简单. 那题大概是这样的,一个冰塔,第一次踩某块会碎,第二次踩碎的会掉落.然后求可行解. 但是 ...

  7. 「日常训练」School Marks(Codeforces Round 301 Div.2 B)

    题意与分析(CodeForces 540B) 题意大概是这样的,有一个考试鬼才能够随心所欲的控制自己的考试分数,但是有两个限制,第一总分不能超过一个数,不然就会被班里学生群嘲:第二分数的中位数(科目数 ...

  8. 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)

    2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...

  9. 「专题训练」Hard problem(Codeforces Round #367 Div. 2 C)

    题意与分析 题意:给出\(n\)个字符串,可以反转任意串,反转每个串都有其对应的花费\(c_i\).经过操作后是否能满足字符串\(\forall i \in [1,n] \text{且} i \in ...

随机推荐

  1. Servlet是线程安全的吗

    Servlet默认是单例模式,在web容器中只创建一个实例,所以多个线程同时访问Servlet是不安全的. 解决此类问题的办法是: 只要Servlet实现 SingleThreadModel 接口

  2. linux iptables 开启和关闭服务端口号

    需求: 模拟数据库挂掉,服务正常但访问数据库报错,恢复数据库端口后,服务是否能正常访问数据库 步骤:首先,断掉端口号5432,测试服务运行情况:其次,开启端口号5432,测试服务运行情况: 具体操作: ...

  3. Web打印连续的表格,自动根据行高分页

    拿到这个需求,我已经蛋碎了一地,经过N天的攻克,终于是把它搞定了,只是不知道会不会在某种情况下出现BUG.表示我心虚没有敢做太多的测试.... ---------------------------- ...

  4. python3带tkinter窗口的ftp服务器,并使用pyinstaller打包成exe

    python带tkinter窗口的ftp服务器,使用python3编写,打包使用pyinstaller,命令 pyinstaller -F .\ftpserver.py 代码也可在我的github上下 ...

  5. Oracle12C创建用户遇到ora-6509

    引用自:http://blog.itpub.net/29357786/viewspace-1995055/ ORACLE 12C创建用户之ORA-65096 2016年2月25日,一北京北方人瑞教育咨 ...

  6. hdu_4336_Card Collector

    In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, fo ...

  7. JavaBen 中 如何将字段设置为 "text" 文本类型

    @Lob @Column(name="FEEDBACK_MESSAGE",columnDefinition="TEXT", nullable=true) pub ...

  8. 微信小程序调用api接口

    请求的第三方微信url大概有3种 1)$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&s ...

  9. day 23 模块2

    1.namedtuple     命名元组  -> 类似创建一个类 from collections import namedtuple   # 类 p = namedtuple("P ...

  10. 06 day小数据池

    1.小数据池,id() 小数据池针对的是: int ,str,bool-----都是不可变的数据类型  a.int 类型 a = 1000 b = 1000 print(id(a), id(b))   ...