\(\\\)

\(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. CentOS 7防火墙服务FirewallD指南

    CentOS 7防火墙服务FirewallD指南 作者:chszs,未经博主同意不得转载.经许可的转载需注明作者和博客主页:http://blog.csdn.net/chszs 防火墙是一种位于内部网 ...

  2. [React] Validate Compound Component Context Consumers

    If someone uses one of our compound components outside the React.createContext <ToggleContext.Pro ...

  3. YII数据流程浅析

    MVC就不解释,直接上代码分析数据流程: 数据库图: 模型部分介绍: <?php /* * 前两个方法必须写 * 继承自CActiveRecord类 这个类位于 \framework\db\ar ...

  4. rsh 无秘钥登陆配置

    /etc/hosts.equiv里的主机不须要提供password就能够訪问本机./etc/host.equiv 要和~/.rhosts文件连用. [root@web-htl2-01 ~]# cat ...

  5. 跨线程访问UI控件时的Lambda表达式

    工作中经常会用到跨线程访问UI控件的情况,由于.net本身机制,是不允许在非UI线程访问UI控件的,实际上跨线程访问UI控件还是 将访问UI的操作交给UI线程来处理的, 利用Control.Invok ...

  6. android 3G移植【转】

    本文转载自:http://blog.csdn.net/hanmengaidudu/article/details/17028383 一 开发环境简介 内容 说明 3G模块 华为EM820W(WCDMA ...

  7. iOS中打包.a静态库

    1.新建.a静态库工程 需要选择Static Library静态库工程模板新建工程,如下图: 新建静态库工程 实现需要打包的类,如下图: 实现需要打包的类 2.设置需要暴露的头文件 添加Headers ...

  8. 8 Range 对象

    8.1 引用Range 引用Range的主要方法: Application.ActiveCell Application.Range Application.Selection Worksheet.C ...

  9. 洛谷 P3960 [ NOIP 2017 ] 列队 —— 线段树

    题目:https://www.luogu.org/problemnew/show/P3960 NOIP 题,不用很复杂的数据结构...但又参考了许多: 要求支持维护删除第 k 个和在末尾插入的数据结构 ...

  10. Postgresql的一些命令

    显示所有数据表: \dt 显示表结构:  \d YOUR_TABLE 进入数据库: psql DATABASE_NAME 显示所有数据库: \list 退出: \q 删除数据库: dropdb DAT ...