\(\\\)

\(Description\)


若\(x\)分解质因数结果为\(x=p_1^{k_1}p_2^{k_2}\cdots p_n^{k_n}\),令\(f(x)=(k_1+1)(k_2+1)\cdots (k_n+1)\)。

求\(\sum_{i=l}^rf(i)\)对\(998244353\)取模的结果。

  • \(l,r\in [1,10^{14}]\)

\(\\\)

\(Solution\)


首先要知道这里定义的 \(f\) 函数的值其实就是这个数的因数个数。

连乘的含义是容斥原理,考虑要构成的约数从每一个质因子里分别选取了多少个,所以有指数加一连乘的种类数。

然后所求就变成了区间内每个数的因子个数之和,问题可以转化为前缀相减。

然后考虑区间\([1,N]\)内所有数的因子个数之和,这个东西可以枚举这个因子是什么,即

\[ans=\sum_{d=1}^N \lfloor\frac{N}{d} \rfloor
\]

然后就是除法分块的板子了。

\(\\\)

\(Code\)


#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define R register
#define gc getchar
#define N 4000010
using namespace std;
typedef long long ll; inline ll rd(){
ll x=0; bool f=0; char c=gc();
while(!isdigit(c)){if(c=='-')f=1;c=gc();}
while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=gc();}
return f?-x:x;
} ll n,a[N];
int res,ans[N]; int main(){
n=rd();
for(R int i=1;i<=n;++i) a[i]=rd();
for(R int i=1,r=1;i<=n;++i){
if(r<i) r=i;
while(r<n&&a[r+1]%a[i]==0) ++r;
ans[i]=r;
}
for(R int i=n,l=n;i>0;--i){
if(l>i) l=i;
while(l>1&&a[l-1]%a[i]==0) --l;
res=max(res,ans[i]-l+1);
}
printf("%d",res);
return 0;
}

[ Luogu 3935 ] Calculating的更多相关文章

  1. [洛谷3935]Calculating

    题目链接:https://www.luogu.org/problemnew/show/P3935 首先显然有\(\sum\limits_{i=l}^rf(i)=\sum\limits_{i=1}^rf ...

  2. 长时间停留在calculating requirements and dependencies 解决方案

    如果Eclipse花费了很长的时间calculating requirements and dependencies(计算需求和依赖性 ) 这个问题通常就是在点击安装之后显示“Calculating ...

  3. Luogu 魔法学院杯-第二弹(萌新的第一法blog)

    虽然有点久远  还是放一下吧. 传送门:https://www.luogu.org/contest/show?tid=754 第一题  沉迷游戏,伤感情 #include <queue> ...

  4. 长时间停留在calculating requirements and dependencies 的解决方案

    如果Eclipse花费了很长的时间calculating requirements and dependencies(计算需求和依赖性 ) 这个问题通常就是在点击安装之后显示“Calculating ...

  5. Calculating Stereo Pairs

    Calculating Stereo Pairs Written by Paul BourkeJuly 1999 Introduction The following discusses comput ...

  6. luogu p1268 树的重量——构造,真正考验编程能力

    题目链接:http://www.luogu.org/problem/show?pid=1268#sub -------- 这道题费了我不少心思= =其实思路和标称毫无差别,但是由于不习惯ACM风格的题 ...

  7. Calculating simple running totals in SQL Server

    Running total for Oracle: SELECT somedate, somevalue,SUM(somevalue) OVER(ORDER BY somedate ROWS BETW ...

  8. [luogu P2170] 选学霸(并查集+dp)

    题目传送门:https://www.luogu.org/problem/show?pid=2170 题目描述 老师想从N名学生中选M人当学霸,但有K对人实力相当,如果实力相当的人中,一部分被选上,另一 ...

  9. [luogu P2647] 最大收益(贪心+dp)

    题目传送门:https://www.luogu.org/problem/show?pid=2647 题目描述 现在你面前有n个物品,编号分别为1,2,3,--,n.你可以在这当中任意选择任意多个物品. ...

随机推荐

  1. Ubuntu 16.04系统启动时卡在:(initramfs)

    背景: 由于不正常的关机和重启,或者突然断电导致的关机,下次起来后不能进去系统,停留在(initramfs). 解决方法: 使用如下命令修复 fsck -y /dev/sda1 说明:其中sda1为系 ...

  2. JSP中访问数据库

    在JSP中访问数据库使用的是JSTL标签,本文不按照http://wiki.jikexueyuan.com/project/jsp/database-access.html此方法进行实践,而是采用之前 ...

  3. Centos7 samba 匿名共享 简单config

    安装Samba yum install samba samba-client samba-common -y 备份原始的Samba配置文件: mv /etc/samba/smb.conf /etc/s ...

  4. {head first} --- networking 1

    Head first系列的书确实非常好,深入浅出解说网络的组成.让曾经那些生涩的概念生动起来. Chapter 1 维修物理网络 CAT5电缆: 两端为RJ-45接头(水晶头).内部为UTP(非屏蔽双 ...

  5. [React] Spread Component Props in JSX with React

    You often find duplication between the name of a prop and a variable you will assign to the prop. JS ...

  6. Ubuntu如何开启root账户登录

    1 首先设置root密码,利用现有管理员帐户登陆Ubuntu,在终端执行命令:sudo passwd root,接着输入密码和root密码,重复密码.这样就有了可用的root用户.   2 打开一个终 ...

  7. 基于Office 365 无代码工作流分析-数据源的建立!

     标准操作步骤 下面整个步骤我们是以嘉昊信息的招聘过程的整个流程为一个场景,整个的流程场景的步骤例如以下: 整个的过程,我们通过Infopath 进行对应的表单流转,然后利用Sharepoint ...

  8. cocos2dx 2.2.3编译第一个apk到安卓手机

    1.android-ndk-r10(注意32位和64位的别下错了 我不小心下错了 折腾了我两天) 2.adt_201407(eclipse已经跟sdk等等集成在一起了)   3.Cococs2d-x ...

  9. B. Amr and The Large Array(Codeforces Round #312 (Div. 2)+找出现次数最多且区间最小)

    B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input st ...

  10. CSP 201612-4 压缩编码 【区间DP+四边形不等式优化】

    问题描述 试题编号: 201612-4 试题名称: 压缩编码 时间限制: 3.0s 内存限制: 256.0MB 问题描述: 问题描述 给定一段文字,已知单词a1, a2, …, an出现的频率分别t1 ...