Output
For each test case, print a single line containing an integer, denoting the answer.
 
Sample Input
3 1 5 1 1 10 2 1 100 3
 
Sample Output
10 48 2302
 
 
题意:就是那个公式

感觉还是题解讲的清楚

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
#define eps 1e-10
#define LL unsigned long long
using namespace std;
const int maxn=+;
const int mod=;
int vis[maxn];
int prim[maxn];
ll a[maxn];
ll b[maxn];
int len;
void get_prim()
{
memset(vis,,sizeof(vis));
int m=sqrt(maxn+0.5);
for(int i=;i<=m;i++)
if(vis[i]==)
for(int j=i*i;j<=maxn;j+=i)
vis[j]=;
len=;
for(int i=;i<=maxn;i++)
if(vis[i]==)
prim[len++]=i;
}
int main()
{
int t;
ll l,r,k;
get_prim();
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld%lld",&l,&r,&k);
for(int i=;i<maxn;i++)
{
a[i]=;
b[i]=i+l;
}
for(int i=;i<len;i++)
{
ll cnt=l;
if(l%prim[i])cnt=l+prim[i]-l%prim[i];
for(ll j=cnt;j<=r;j+=prim[i])
{
int count=;
while(b[j-l]%prim[i]==)
{
count++;
b[j-l]/=prim[i];
}
a[j-l]=((k*count+)%mod*a[j-l])%mod;
}
}
ll ans=;
for(int i=;i<=r-l;i++)
if(b[i]>)
a[i]=(a[i]*(k+))%mod;
for(int i=;i<=r-l;i++)
{
ans=(ans+a[i])%mod;
}
printf("%lld\n",ans);
}
return ;
}
 

HDU 6069 Counting Divisors(2017 Multi-University Training Contest - Team 4 )的更多相关文章

  1. 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 ...

  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 筛法

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

  5. HDU 6069 Counting Divisors(唯一分解定理+因子数)

    http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 思路: 根据唯一分解定理,$n={a_{1}}^{p1}*{a2_{}}^{p2}...*{a_{ ...

  6. 2017ACM暑期多校联合训练 - Team 4 1003 HDU 6069 Counting Divisors (区间素数筛选+因子数)

    题目链接 Problem Description In mathematics, the function d(n) denotes the number of divisors of positiv ...

  7. HDU 6069 Counting Divisors (素数+筛法)

    题意:给定 l,r,k,让你求,其中 l <= r <= 1e12, r-l <= 1e6, k <= 1e7. 析:首先这个题肯定不能暴力,但是给定的区间较小,可以考虑筛选, ...

  8. HDU 6069 Counting Divisors(区间素数筛法)

    题意:...就题面一句话 思路:比赛一看公式,就想到要用到约数个数定理 约数个数定理就是: 对于一个大于1正整数n可以分解质因数: 则n的正约数的个数就是 对于n^k其实就是每个因子的个数乘了一个K ...

  9. hdu 6069 Counting divisors 公式+区间筛

    比赛的时候把公式扣出来了,,但是没有想到用筛法算公因子,,默默学习一下.. 题解:设n=p1^(c1)p2^{c2}...pm^{cm},n=p​1^​c​1*​​​​p​2​^c​2​​​​...p ...

随机推荐

  1. Alpha Edition [ Group 1 ]

    Deltafish Alpha Edition 一.博客归档(记录人:娄雨禛) 小组会议 DeltaFish 校园物资共享平台 第一次小组会议 DeltaFish 校园物资共享平台 第二次小组会议 D ...

  2. tomcat报错org.springframework.web.context.ContextLoaderListener找不到

    tomcat报错org.springframework.web.context.ContextLoaderListener找不到. 最后解决办法:将jar包copy到web-inf下面的lib中. 你 ...

  3. maven——项目构建和依赖管理工具

    apache maven是一个用于项目构建和依赖管理的工具. 添加archetype https://repo1.maven.org/maven2/archetype-catalog.xml 更改本地 ...

  4. CSS——层级

    层级问题:选中的盒子显示的效果并不完整,右边的边框并没有显示红色,原因是其右边的盒子压了它的边框. <!DOCTYPE html> <html lang="en" ...

  5. Android List,Set,Map集合安全 集合区别 并发集合类性能分析

    对于Android开发者来说深入了解Java的集合类很有必要主要是从Collection和Map接口衍生出来的,目前主要提供了List.Set和 Map这三大类的集合 Collection接口主要有两 ...

  6. Photoshop如何实现图片相对画布居中

    先按ctrl+A,再选择要居中的图层,然后就会发现居中按钮被激活了

  7. PHP 设计模式--序言

    面向对象是PHP5之后增加的功能,是PHP走向现代语言的一个标志. 在过程式设计时代,PHP以学习成本低.入门快的特点赢得很多WEB开发者的青睐,但同时也限制了PHP的发展. 借鉴Java和C++之后 ...

  8. java堆排序实现

    代码如下: public class HeapSort { public static void heapSort(DataWrap[] data) { System.out.println(&quo ...

  9. Python 查看关键字

    关键字 import keyword print(keyword.kwlist)

  10. 浏览器控制之 selenium,phantomJs谷无头浏览器

    目录 浏览器控制之 selenium,phantomJs谷无头浏览器 selenium phantomJs 需求是尽可能多的爬取豆瓣网中的电影信息 谷歌无头浏览器 浏览器控制之 selenium,ph ...