cf550C. Divisibility by Eight(结论)
题意
给出长度为$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(结论)的更多相关文章
- Codeforces 922.F Divisibility
F. Divisibility time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论
异常汇总:http://www.cnblogs.com/dunitian/p/4523006.html#signalR 后台创建了一个DntHub的集线器 前台在调用的时候出现了问题(经检查是代理对象 ...
- 《一个 Go 程序系统线程暴涨的问题》结论
原文地址:https://zhuanlan.zhihu.com/p/22474724 作者的结论没写好,我来说两句.. 结论: Docker swarm自己有个函数,叫setTcpUserTimeou ...
- cf306 C. Divisibility by Eight(数学推导)
C. Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- android View事件分发机制结论
原始博客有对源码的分析:http://blog.csdn.net/lmj623565791/article/details/39102591 结论:1.view事件的分发流程: dispatchTou ...
- 关于网络上的各种mysql性能测试结论
关于网上的各种性能测试帖子,我想说以下几点: 1.为了使性能测试更加的客观.实际,应该说明针对什么场景进行测试,查询.还是修改,是否包含了主键,包含了几个索引,各自的差别是什么.因为不同的mysql分 ...
- 周赛-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 ...
- 最大化 AIX 上的 Java 性能,第 5 部分: 参考资料和结论
http://www.ibm.com/developerworks/cn/aix/library/es-Javaperf/es-Javaperf5.html 最大化 AIX 上的 Java 性能,第 ...
- 一个关于正整数x的约数个数的结论
分析理解:x的每一个约数都是由x的若干个质因数的积构成. 再根据乘法原理,每个质因数Pi的选择可以是0~Ni个,所以上述结论成立.
随机推荐
- 未找到与约束 Micorosoft.CodeAnalysis.Editor.TypeScript.ToolsOptions.IUserSettingsProvider
问题: 未找到与约束 ContractName Micorosoft.CodeAnalysis.Editor.TypeScript.ToolsOptions.IUserSettingsProvide ...
- Angular2.0的学习(三)
第三节课:依赖注入 1.什么是依赖注入模式及使用依赖注入的好处 2.介绍Angular的依赖注入实现:注入器和提供器 3.注入器的层级结构
- wms-springmvc-servlet.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- ssl加密
握手前使用非对称加密, 握手后使用对称加密 前期握手就是用来协商对称加密算法的
- 【ElasticSearch+NetCore 第一篇】在Windows上安装部署ElasticSearch和ElasticSearch-head
ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为Apach ...
- c++的直接初始化与复制初始化 未完成!!!!!!!!!!!!
直接初始化:是直接调用类的构造函数进行初始化.如下: string a;//调用默认构造函数 string a("hello");//调用参数为 const char* 类型的构造 ...
- LeetCode 208 Implement Trie (Prefix Tree) 字典树(前缀树)
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are ...
- 【Unity3D/C#】利用IEnumerable<>和yield产生斐波那契数列
using UnityEngine; using System.Collections; using System.Collections.Generic; public class YieldTes ...
- (六)Redis主从自动恢复-sentinel
原文地址,转载请注明出处: http://blog.csdn.net/qq_34021712/article/details/72026313 ©王赛超 准备工作:(1个master,2个sl ...
- HDU 2586——How far away ?——————【LCA模板题】
How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...