cf D. Pair of Numbers】的更多相关文章

http://codeforces.com/contest/359/problem/D 题意:给你n个数,然后找出在[l,r]中有一个数a[j],l<=j<=r,在[l,r]中的所有数都是a[j]的倍数.找出符合这样的r-l最长长度的个数,输出r-l最长长度的个数和长度,然后输出符合的l的序列. 枚举每一个数,然后向左找到l,向右找到r,r-l就是所求的符合一种,这样就可以找到最长的长度 #include <cstdio> #include <cstring> #inc…
D. Pair of Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l…
D. Pair of Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l…
Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold: there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, …
D. Beautiful numbers 链接 题意: 求[L,R]中多少个数字可以整除它们的每一位上的数字. 分析: 要求模一些数字等于0等价于模它们的lcm等于0,所以可以记录当前出现的数字的lcm,最后判断组成的数字是否模lcm等于0. 但是这个数字太大记录不下.根据一个性质a%b=(a%kb)%b,所以可以记录当前的数字模2520的值,最后模一下lcm. 这样的状态是$20 \times 2520 \times 2520$的,状态太大了,考虑如何缩小空间.因为1~9的lcm只能是50个左…
题意:给定一个正整数数组,求最长的区间,使得该区间内存在一个元素,它能整除该区间的每个元素. 析:暴力每一个可能的区间,从数组的第一个元素开始考虑,向两边延伸,设延伸到的最左边的点为l, 最右边的点为r.那么我们下一点考虑r+1即可, 因为[l, r]之间不会有更优解. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string>…
Codeforces Round #209 (Div. 2) D:http://codeforces.com/contest/359/problem/D 题意:给以一个n个数的序列,然后问你最大的区间l,r,在这个区间里面,存在一个数是这个区间所有数的约数,如果这个区间有多个,统计有多少个以及每个区间的左端点. 题解:这一题,别人用了一个很特殊的找发,让我叹为观止.哎,没有数学功底以及很强的推理能力,真的有点力不从心啊.说说别人是怎么找的吧.首先,从第一个数开始,往右边找,然后找到第一个不是a[…
http://codeforces.com/contest/318/problem/C #include <cstdio> #include <cstring> #include <algorithm> using namespace std; long long j; long long x,y,m; int main() { scanf("%I64d%I64d%I64d",&x,&y,&m); if(x>=m||y&…
题目 传送门:QWQ 分析 很难想到方向,但有方向了就很easy了. 我们如何减少不必要的计算? 如果我们知道了$ 100111 $的相容的数,$ 100101 $的相容数和他是完全一样的. 我们就靠着这个思想写一下就行了. 注意位运算优先级. 代码 #include <bits/stdc++.h> using namespace std; <<, INF=(<<)-; int dp[maxn], a[maxn]; int main(){ int n; scanf(&q…
https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数,问一个区间内所有的数是否能被其其中一个数所全部整除,求出满足条件的区间的长度最大值,并输出这样的区间的个数与它们的左端点. 换句话将,求区间GCD=区间MIN的最大长度区间. 明显st表解决. 对于最大区间长度,二分判断即可. (因为在poj做过类似的题所以思路能很快……就是题看不懂有点难,所以特…