题目传送门

 /*
数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案;用到sprintf把数字转移成字符读入
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN];
char t[MAXN]; int main(void) //Codeforces Round #306 (Div. 2) C. Divisibility by Eight
{
while (scanf ("%s", s) == )
{
bool ok = false;
for (int i=; i<; ++i)
{
if (i % == ) sprintf (t, "%d", i);
int p = ;
for (int i=; s[i] && t[p]; ++i)
{
if (s[i] == t[p]) p++;
}
if (!t[p]) {puts ("YES"); printf ("%s\n", t); ok = true; break;}
}
if (!ok) puts ("NO");
} return ;
} /*
3454
10
111111
*/

数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight的更多相关文章

  1. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  2. Codeforces Round #306 (Div. 2) C. Divisibility by Eight 暴力

    C. Divisibility by Eight Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  3. 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad

    题目传送门 /* DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : */ #include <cstdio> #include <iostream&g ...

  5. 水题 Codeforces Round #306 (Div. 2) A. Two Substrings

    题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...

  6. Codeforces Round #486 (Div. 3) E. Divisibility by 25

    Codeforces Round #486 (Div. 3) E. Divisibility by 25 题目连接: http://codeforces.com/group/T0ITBvoeEx/co ...

  7. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  8. 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun

    题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...

  9. 暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II

    题目传送门 /* 暴力:O (n^2) */ #include <cstdio> #include <algorithm> #include <cstring> # ...

随机推荐

  1. vue 定义全局函数

    方法一:main.js 注入 (1)在main.js中写入函数 Vue.prototype.changeData = function (){ alert('执行成功'); } (2)在所有组件里可调 ...

  2. Zookeeper 3.4 官方文档翻译

    说明 个人英语水平非常一般,理解可能有偏差,假设有翻译不恰当之处,请看官指点. 1.简单介绍 分布式系统就像动物园.当中每台server就像一仅仅动物,Zookeeper就像动物园管理员,协调.服务于 ...

  3. android &lt;application&gt; 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客仅仅要没有注明"转",那么均为原创.转贴请注明本博客链接链接 <application>语法:    <appl ...

  4. string 是值类型,还是引用类型(.net)[转]

    转自http://hi.baidu.com/newfzks/item/b805f0f4edb0810dd89e7290 string 是值类型,还是引用类型(.net) 一. string 类型的用法 ...

  5. java方法返回值的变量类型困惑

    一.java program progress of excuting:show in next picture        How about the java virtual machine i ...

  6. 【bzoj3224】Tyvj 1728 普通平衡树

    交了一发pb_ds #include<ext/pb_ds/assoc_container.hpp> #include<algorithm> #include<iostre ...

  7. transport transmission

    运输层 transport layer 传输控制协议 transmission control protocol

  8. 设计模式-(13)访问者模式 (swift版)

    一,概念 访问者模式,是行为型设计模式之一.访问者模式是一种将数据操作与数据结构分离的设计模式,它可以算是 23 中设计模式中最复杂的一个,但它的使用频率并不是很高,大多数情况下,你并不需要使用访问者 ...

  9. javaScript改变HTML

    改变HTML输出流: 在JavaScript中,document.write() 可用于直接向HTML输出流写内容 <!DOCTYPE html> <html> <bod ...

  10. div内鼠标坐标位置及绝对和相对坐标获取

    JQuery 获得div绝对,相对位置的坐标方法   1 2 3 4 5 6 获取页面某一元素的绝对X,Y坐标 var X = $('#DivID').offset().top; var Y = $( ...