HDU 5288
//枚举因子,查找和i最近的左右是i因子的点即可。 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define LL long long
using namespace std; const int MAX=100010;
const LL mod=1e9+7;
int l_next[10010];
int r_next[10010];
int num[MAX];
int l[MAX],r[MAX]; int main(){
int n;
while(scanf("%d",&n)!=EOF){
for(int i=1;i<=n;i++){
scanf("%d",&num[i]);
l[i]=0;r[i]=MAX;
}
for(int i=0;i<10010;i++){
l_next[i]=0; r_next[i]=MAX;
}
for(int i=1;i<=n;i++){
int lmax=0;
for(int k=1;k*k<=num[i];k++){
if(num[i]%k==0){
lmax=max(lmax,l_next[k]);
// if(k!=1)
lmax=max(lmax,l_next[num[i]/k]);
}
}
l[i]=lmax;
l_next[num[i]]=i;
}
/* for(int i=1;i<=n;i++)
cout<<l[i]<<" ";
cout <<endl;*/
for(int i=n;i>=1;i--){
int rmin=n+1;
for(int k=1;k*k<=num[i];k++){
if(num[i]%k==0){
rmin=min(rmin,r_next[k]);
// if(k!=1)
rmin=min(rmin,r_next[num[i]/k]);
}
}
r[i]=rmin;
r_next[num[i]]=i;
}
/* for(int i=1;i<=n;i++)
cout<<r[i]<<" ";
cout <<endl;
*/
LL ans=0;
for(int i=1;i<=n;i++){
ans+=(LL)(i-l[i])*(LL)(r[i]-i);
ans%=mod;
}
printf("%lld\n",ans); }
return 0;
}
HDU 5288的更多相关文章
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- HDU 5288 OO’s Sequence [数学]
HDU 5288 OO’s Sequence http://acm.hdu.edu.cn/showproblem.php?pid=5288 OO has got a array A of size ...
- HDU 5288 OO‘s sequence (技巧)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5288 题面: OO's Sequence Time Limit: 4000/2000 MS (Jav ...
- hdu 5288 OO’s Sequence(2015多校第一场第1题)枚举因子
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5288 题意:在闭区间[l,r]内有一个数a[i],a[i]不能整除 除去自身以外的其他的数,f(l,r ...
- HDU 5288 OO’s Sequence 水题
OO's Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5288 Description OO has got a array A ...
- hdu 5288 数学 ****
给一个序列 定义函数f(l ,r) 为区间[l ,r] 中 的数ai不是在这个区间其他任意数aj的倍数 求所有f(l,r)之和 通过预处理,记录 a[i] 的左右边界(所谓的左右边界时 在从 a[i] ...
- hdu 5288 OO’s Sequence 枚举+二分
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number o ...
- HDU 5288 OO’s Sequence
题意:给一个序列,函数f(l, r)表示在[l, r]区间内有多少数字不是其他数字的倍数,求所有区间的f(l, r)之和. 解法:第一次打多校……心里还有点小激动……然而一道签到题做了俩点……呜呜呜… ...
- hdu 5288 OO’s Sequence(计数)
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number o ...
- HDU 5288 OO’s Sequence
题意: 给你一个序列, 有一个函数 F(L,R) 其中 ai 均不能 被 aL - aR整除的 函数值是这个ai个数 思路 : 反过来求 满足这样的条件的 ai 的区间,然后求和 #include& ...
随机推荐
- max_allowed_packet设置问题
最近在运行的项目出现了一个线上事故,有人反映商城的东西下不了单了,到后台看了一下,果然报了一个错 Cause: com.mysql.jdbc.PacketTooBigException: Packet ...
- drawable的文件名大写
drawable的文件名大写导致的R文件消失!!!1
- EasyUI系列学习(三)-Draggable(拖动)
一.创建拖动组件 0.Draggable组件不依赖于其他组件 1.使用标签创建 <div class="easyui-draggable" id="box" ...
- Django用户认证系统
一. 认证系统概要 create_user 创建用户 authenticate 验证登录 login 记住用户的登录状态 logout 退出登录 is_authenticated 判断用户是否登录 l ...
- RTL Compiler之synthesis flow
1 generic RTL Compiler work flow 2 invoking RTL compiler RTL Compiler is invoked from the operating ...
- 转录组入门(3):了解fastq测序数据
sra文件转换为fastq格式 fastq-dump -h --split-3 也就是说如果SRA文件中只有一个文件,那么这个参数就会被忽略.如果原文件中有两个文件,那么它就会把成对的文件按*_1.f ...
- 内网jenkins如何配置gitlab自动拉取代码打包
在全局工具配置中添加git安装目录的配置 http://10.2.1.92:8080/jenkins/configureTools/git1.8.3.1/usr/bin/git 打开系统设置配置git ...
- 中望CAD VBA检测文件是否存在
Option Explicit Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "Path ...
- ubuntu.16.04 安装.net core记录
jack@ubuntu:~$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotne ...
- 2019 支付宝App支付 --- PHP
SDK下载:https://docs.open.alipay.com/54/106370/;联系客服:https://cschannel.alipay.com/newPortal.htm?scene= ...