题意

给出长度为$n$的字符串,判断是否能删除一些数后被$8$整除

Sol

神仙题啊Orz

结论:

若数字的后三位能被$8$整除,则该数字能被$8$整除

证明

设$x = 10000 * a_i + 1000 * a_{i - 1} + \dots$

发现大于$3$的位都会分解出$8$这个因数

然后大力枚举三个位置即可

/*
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N;
int a[MAXN];
char s[MAXN];
main() {
scanf("%s", s + );
N = strlen(s + );
for(int i = ; i <= N; i++) a[i] = s[i] - '';
for(int i = ; i <= N; i++)
if(a[i] % == ) {printf("YES\n%d", a[i]); return ;}
for(int i = ; i <= N; i++) {
for(int j = i + ; j <= N; j++) {
int tmp = a[i] * + a[j];
if(tmp % == ) {printf("YES\n%d", tmp); return ;}
}
}
for(int i = ; i <= N; i++) {
for(int j = i + ; j <= N; j++) {
for(int k = j + ; k <= N; k++) {
int tmp = a[i] * + a[j] * + a[k];
if(tmp % == ) {printf("YES\n%d", tmp); return ;}
}
}
}
puts("NO");
return ;
}
/*
2 2 1
1 1
2 1 1
*/

cf550C. Divisibility by Eight(结论)的更多相关文章

  1. Codeforces 922.F Divisibility

    F. Divisibility time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论

    异常汇总:http://www.cnblogs.com/dunitian/p/4523006.html#signalR 后台创建了一个DntHub的集线器 前台在调用的时候出现了问题(经检查是代理对象 ...

  3. 《一个 Go 程序系统线程暴涨的问题》结论

    原文地址:https://zhuanlan.zhihu.com/p/22474724 作者的结论没写好,我来说两句.. 结论: Docker swarm自己有个函数,叫setTcpUserTimeou ...

  4. cf306 C. Divisibility by Eight(数学推导)

    C. Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. android View事件分发机制结论

    原始博客有对源码的分析:http://blog.csdn.net/lmj623565791/article/details/39102591 结论:1.view事件的分发流程: dispatchTou ...

  6. 关于网络上的各种mysql性能测试结论

    关于网上的各种性能测试帖子,我想说以下几点: 1.为了使性能测试更加的客观.实际,应该说明针对什么场景进行测试,查询.还是修改,是否包含了主键,包含了几个索引,各自的差别是什么.因为不同的mysql分 ...

  7. 周赛-Clique in the Divisibility Graph 分类: 比赛 2015-08-02 09:02 23人阅读 评论(3) 收藏

    Clique in the Divisibility Graph time limit per test1 second memory limit per test256 megabytes inpu ...

  8. 最大化 AIX 上的 Java 性能,第 5 部分: 参考资料和结论

    http://www.ibm.com/developerworks/cn/aix/library/es-Javaperf/es-Javaperf5.html 最大化 AIX 上的 Java 性能,第 ...

  9. 一个关于正整数x的约数个数的结论

    分析理解:x的每一个约数都是由x的若干个质因数的积构成. 再根据乘法原理,每个质因数Pi的选择可以是0~Ni个,所以上述结论成立.

随机推荐

  1. codeforces1016 D. Vasya And The Matrix(思维+神奇构造)

    D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. linux查看硬盘空间,删除大文件

    df -Phdu -h --max-depth=1du -sh /u02/weblogic/user_projects/domains/logsdu -sh /u02/mysqlfind / -siz ...

  3. applicationContext-datasource.xml

    <?xml version="1.0" encoding="utf-8"?> <beans default-init-method=" ...

  4. HDU 6153 A Secret 套路,求解前缀在本串中出现的次数

    http://acm.hdu.edu.cn/showproblem.php?pid=6153 首先相当于翻转两个串,然后求s2前缀在s1中出现的次数. 这是一个套路啦 首先把两个串结合起来,中间加一个 ...

  5. php安装错误 (node.c:1953:error) 解决办法

    CentOs安装PHP在make时报错: root@---- [/opt/php-5.2.17]# make /bin/sh /opt/php-5.2.17/libtool --silent --pr ...

  6. Spring AOP的增强处理

    就是@Before @Around @AfterReturning @AfterThrowing这几个标签的属性可以放到方法参数里面获取 例子 //正常操作@Around("service( ...

  7. <Linux系统minfo命令用法>

    minfo命令——ms-dos文件系统的各项参数的显示 minfo这个指令主要用于显示MS-DOS文件系统的各项参数,包括扇区数.磁头数.柱面数等. 参数主要有以下几个: -v 显示详细的参数 dri ...

  8. 分享一个WPF下日历控件(Calendar)的样式

    WPF日历控件的一个样式 WPF自带的日历控件样式可能会比较丑,要修改其样式看起来挺复杂的,实际上很简单,用Blend打开,修改三个模板,基本就能改变全部面貌,也很容易 先上图 样式如下: <S ...

  9. java-类的定义和用法

    1.类的定义 public class Human{ }//每个源文件必须也只能有一个public类 class boy{ }//可以定义多个class类 class girl{ } 上面的类定义好后 ...

  10. ABAP WRITE

    1.空行 WRITE /. 2.AS CHECKBOX VALUE 'X', check2 VALUE ' '. START-OF-SELECTION. WRITE: / check1 AS CHEC ...