设n=p_1^{c_1}p_2^{c_2}...p_m^{c_m}n=p​1​c​1​​​​p​2​c​2​​​​...p​m​c​m​​​​,则d(n^k)=(kc_1+1)(kc_2+1)...(kc_m+1)d(n​k​​)=(kc​1​​+1)(kc​2​​+1)...(kc​m​​+1)。

枚举不超过\sqrt{r}√​r​​​的所有质数pp,再枚举区间[l,r][l,r]中所有pp的倍数,将其分解质因数,最后剩下的部分就是超过\sqrt{r}√​r​​​的质数,只可能是00个或11个。

时间复杂度O(\sqrt{r}+(r-l+1)\log\log(r-l+1))O(√​r​​​+(r−l+1)loglog(r−l+1))。

这道题的出题者给我膜一会,666666

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N=1000010,P=998244353;
int Case,i,j,k,p[N/10],tot,g[N],ans;ll n,l,r,f[N];
bool v[N]; void work(ll p)
{
for(ll i=l/p*p;i<=r;i+=p)if(i>=l)
{
int o=0;
while(f[i-l]%p==0)f[i-l]/=p,o++;
g[i-l]=1LL*g[i-l]*(o*k+1)%P;
}
} int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
for(i=2;i<N;i++)
{
if(!v[i]) p[tot++]=i;
for(j=0;j<tot && i*p[j]<N;j++)
{
v[i*p[j]]=1;
if(i%p[j]==0) break;
}
}
scanf("%d",&Case);
while(Case--)
{
scanf("%lld%lld%d",&l,&r,&k);
n=r-l;
for(i=0;i<=n;i++) f[i]=i+l,g[i]=1;
for(i=0;i<tot;i++)
{
if(1LL*p[i]*p[i]>r)break;
work(p[i]);
}
for(ans=i=0;i<=n;i++)
{
if(f[i]>1)g[i]=1LL*g[i]*(k+1)%P;
ans=(ans+g[i])%P;
}
printf("%d\n",ans);
}
return 0;
}

Counting Divisors HDU - 6069的更多相关文章

  1. HDU 6069 Counting Divisors

    Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Oth ...

  2. hdu 6069 Counting Divisors(求因子的个数)

    Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Oth ...

  3. hdu 6069 Counting Divisors 筛法

    Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Oth ...

  4. HDU 6069 Counting Divisors —— 2017 Multi-University Training 4

    Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Oth ...

  5. 2017 Multi-University Training Contest - Team 4 hdu6069 Counting Divisors

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6069 题目: Counting Divisors Time Limit: 10000/5000 ...

  6. hdu6069 Counting Divisors 晒区间素数

    /** 题目:hdu6069 Counting Divisors 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意:求[l,r]内所有数的k次方 ...

  7. HDU 6069

    Counting Divisors Problem Description In mathematics, the function d(n) denotes the number of diviso ...

  8. DIVCNT2&&3 - Counting Divisors

    DIVCNT2 - Counting Divisors (square) DIVCNT3 - Counting Divisors (cube) 杜教筛 [学习笔记]杜教筛 (其实不算是杜教筛,类似杜教 ...

  9. SPOJ 20713 DIVCNT2 - Counting Divisors (square)

    DIVCNT2 - Counting Divisors (square) #sub-linear #dirichlet-generating-function Let \sigma_0(n)σ​0​​ ...

随机推荐

  1. ubuntu opencv的使用

    博客转载自:https://blog.csdn.net/u012816621/article/details/51732932 CMakeLists.txt # cmake needs this li ...

  2. Hyperledger Fabric系统架构

  3. Django--model模型绑定_数据库操作

    1.创建model类 app01/models.py 1 2 3 4 5 6 7 from django.db import models   # Create your models here. c ...

  4. selenium使用ChromeDriver

    什么是ChromeDriver? ChromeDriver是Chromium team开发维护的,它是实现WebDriver有线协议的一个单独的服务.ChromeDriver通过chrome的自动代理 ...

  5. selenium+phantomjs解析JS

    背景知识: PhantomJS 是一个基于WebKit的服务器端 JavaScript API.它全面支持web而不需浏览器支持,其快速,原生支持各种Web标准: DOM 处理, CSS 选择器, J ...

  6. dev初识 拖动分组

    1.前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm ...

  7. Shell内置命令

    主要Shell内置命令 Shell有很多内置在其源代码中的命令.这些命令是内置的,所以Shell不必到磁盘上搜索它们,执行速度因此加快.不同的Shell内置命令有所不同. A.2.1  bash内置命 ...

  8. JavaScript跨域调用基于JSON的RESTful API

    1. 基本术语 AJAX(Asynchronous JavaScript And XML,异步JavaScript和XML):AJAX是一种用于创建快速动态网页的技术,通过在后台与服务器进行少量数据交 ...

  9. delphi 指针 认识

    delphi 指针分为类型指针和无类型指针: 类型指针分为PChar.PInteger.PString等. 无类型指针Pointer. PPChar/PP...为指针的指针 @和Addr一样,为获取变 ...

  10. .net Stream篇(五)

    MemoryStream 目录: 1 简单介绍一下MemoryStream 2 MemoryStream和FileStream的区别 3 通过部分源码深入了解下MemoryStream 4 分析Mem ...