[YY题]HDOJ5288 OO’s Sequence】的更多相关文章

题意:求这个式子 $\sum \limits_{i=1}^{n} \sum \limits_{j=1}^{m} f(i, j) mod (10^9 + 7)$ 的值 就是对每个区间[i, j]枚举区间中的每个数$a_i$到$a_j$, 判断这个$a$是否对[i, j]这个区间内所有数取模都不等于0, 若是,则这个区间满足条件 问有多少个满足条件的区间 比如案例是这样跑的 ; ;i<=;i++) ;j++) { for(int k=i;k<=j;k++) // 注意要枚举[i, j]中的每个数…
OO's Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5288 Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO wan…
OO’s Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1549    Accepted Submission(s): 559 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the nu…
OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1751    Accepted Submission(s): 632 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the n…
题目传送门 /* 定义两个数组,l[i]和r[i]表示第i个数左侧右侧接近它且值是a[i]因子的位置, 第i个数被选择后贡献的值是(r[i]-i)*(i-l[i]),每个数都枚举它的因子,更新l[i], r[i],复杂度O(n*sqrt(a[i])) */ #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <map> using…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5288 题面: OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 985    Accepted Submission(s): 375 Problem Description OO has got a arra…
预处理出每一个数字的左右两边能够整除它的近期的数的位置 OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1880    Accepted Submission(s): 672 Problem Description OO has got a array A of size n ,defined a fun…
 HDU 5288 OO’s Sequence http://acm.hdu.edu.cn/showproblem.php?pid=5288 OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there’s no j(l<=j<=r,j<>i) satisfy a i mod a j=0,now OO want to k…
OO’s Sequence Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5288 Mean: 给定一个数列,让你求所有区间上满足Ai%Aj!=0(Ai!=Aj)的Ai的个数之和. analyse: 对于Ai,如果我们知道最靠近Ai且能够整除Ai的数的下标l和r,那么Ai对答案的贡献就是(r-i)*(i-l).剩下的就是怎样去求每个Ai的l和r了. 首先我们预处理出:对于每个i,能够被1~i整除的数,用链表存起来. 那么对于输…
OO's Sequence                                                          Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                                             T…
OO’s Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 312    Accepted Submission(s): 107 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the num…
OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 42    Accepted Submission(s): 21 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the numb…
题目大意: 给你一个序列A,f(l,r) 表示 在[l,r]中 的Ai 对于每一个数Aj 都有 Ai%Aj!=0  的数目(  i!=j  ) 卡了一段时间..... 题解 简单题 定义两个数组L[i],R[i],表示第i数左侧和右侧最接近它且值是A[i]因子的数的位置,那么第i个数贡献的答案就是(R[i]-i ) * (i-L[i]) #include <cstdio> #include <cstdlib> #include <cmath> #include <…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5288 题意:在闭区间[l,r]内有一个数a[i],a[i]不能整除 除去自身以外的其他的数,f(l,r)表示在这区间内a[i]这样的数的个数,,现给你n个数,求所有区间的f(l,r)的和. 思路:对于每个数a[i]求出他的左右侧最靠近他的且是他的因子的位置L.R,并记录,那么对于每个数a[i]都有了他的L,R,而对于每个a[i]在f(l,r)有价值的次数之和就是(i-L+1)*(R-i+1) 代码:…
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know     Input There are multiple test cases. Please p…
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3): Given n and k, return the kth permutation sequence. Note: Given n will be between…
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i=1n∑j=inf(i,j) mod (109+7).   Input There are m…
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i=1n∑j=inf(i,j) mod (109+7).   Input There are m…
题意:给一个序列,函数f(l, r)表示在[l, r]区间内有多少数字不是其他数字的倍数,求所有区间的f(l, r)之和. 解法:第一次打多校……心里还有点小激动……然而一道签到题做了俩点……呜呜呜……今天的题还算简单……明天就更难了……写个题解纪念一下多校…… 对于序列中的每一个数,要找到从它的位置起向左右找最远连续不能被它整除的数的位置设为l和r,这个数的位置为pos,答案就是(pos - l + 1) * (r - pos + 1),只要分析一下样例就可以得到这个式子……然后为了找到l和r…
题目链接 题意:从1号点走到n号点(每条边只能走一次, 两结点间的边数必定为奇数) 问 经过结点不同顺序的方式有多少种(如1->2->3->4和1->3->2->4为两种) 方法数模上1000000007 此题只需先考虑相邻两结点交替的方法数 然后依次递推相乘即可 就是:如从1走到5 只需先考虑2.3交替的方法数:(很明显与边数有关的组合数) 然后类似的考虑3.4交替的方法数 最后全部相乘就可以了 公式是$\displaystyle\prod\limits_{i=1}^…
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i=1n∑j=inf(i,j) mod (+). Input There are multipl…
描述 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. 示例 Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4]. Return its…
将1~n压入最多为m元素的栈 给出k个出栈序列,问你是否能够实现. 能输出YES 否则NO 模拟一遍即可,水题. #include <iostream> #include <cstdio> #include <string.h> #include <algorithm> using namespace std; ; int m,n,k; int seq[maxn]; int stacks[maxn]; ; int main() { int val; scan…
题目: Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subsequence of the original sequence. Every part must satisfy that the sum of the integers in the part is…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5288 //*************头文件区************* #include<iostream> #include<cstdio> #include<vector> #define N 100010 #define P 1000000007 using namespace std; int n,tmp,i,j; int r[N], l[N], q[N], a[N…
二分寻找对于指定pos的最左因数点和最右因数点. /* 5288 */ #include <iostream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorithm> #includ…
题意: 给你一个序列, 有一个函数 F(L,R) 其中 ai 均不能 被 aL - aR整除的  函数值是这个ai个数 思路 : 反过来求 满足这样的条件的 ai 的区间,然后求和 #include<iostream> #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef __int64 LL; ;…
题意:给定一个长度为n的序列,规定f(l,r)是对于l,r范围内的某个数字a[i],都不能找到一个相应的j使得a[i]%a[j]=0.那么l,r内有多少个i,f(l,r)就是几. 问全部f(l,r)的总和是多少. 公式中给出的区间,也就是全部存在的区间. 思路:直接枚举每个数字,对于这个数字,假设这个数字是合法的i,那么向左能扩展的最大长度是多少,向右能扩展的最大长度是多少.那么i为合法的情况就是左长度*右长度(包括i且i是合法的区间总数). 统计左长度能够推断a[i]的约数是否在前面出现过-由…
njczy2010 2069 Accepted 31MS   224K 1351Byte G++ 2014-11-13 13:32:56.0 坑爹的无限gcd,,,尼玛想好久,原来要x对y算一次,y再对x算一次,,, 赵信的往事 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 20            测试通过 : 2 描述 赵信——德玛西亚的总管,可谓一人之下,万人之上.但谁能想到,他以前在诺克萨斯的角斗…
链接:http://codeforces.com/problemset/problem/215/C C. Crosses time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is a board with a grid consisting of n rows and m columns, the rows are n…