【区间筛】2017多校训练四 HDU6069 Counting Divisors
http://acm.hdu.edu.cn/showproblem.php?pid=6069
【题意】
给定l,r,k,求
d(n)是n的因子个数
【思路】

【Accepted】
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=1e6+;
const ll mod=;
ll l,r,k;
bool isprime[maxn];
int prime[maxn];
int cnt;
ll tot[maxn];
vector<int> s[maxn];
ll a[maxn];
void init()
{
memset(isprime,true,sizeof(isprime));
isprime[]=false;
for(int i=;i<maxn;i++)
{
if(isprime[i])
{
for(int k=*i;k<maxn;k+=i)
{
isprime[k]=false;
}
}
}
cnt=;
for(int i=;i<maxn;i++)
{
if(isprime[i])
{
prime[cnt++]=i;
}
}
}
ll fac(ll& num,ll p)
{
ll cou=;
while(num%p==)
{
cou++;
num/=p;
}
return cou;
} int main()
{
init();
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld%lld",&l,&r,&k);
for(int i=;i<=r-l;i++)
{
a[i]=(ll)i+l;
tot[i]=;
}
for(int i=;i<cnt;i++)
{
if(prime[i]>r) break;
ll cou=l/(ll)prime[i];
if(l%(ll)prime[i]) cou++;
for(ll j=cou*(ll)prime[i];j<=r;j+=(ll)prime[i])
{
int num=(int)(j-l);
if(a[num]==) continue;
ll sum=fac(a[num],prime[i]);
tot[num]=tot[num]*((k*sum)%mod+)%mod;
}
}
ll ans;
if(l==) ans=;
else ans=;
for(int i=;i<=(int)(r-l);i++)
{
if(a[i]!=) tot[i]=tot[i]*(k+)%mod;
if(tot[i]!=)
ans=(ans+tot[i])%mod;
}
cout<<ans<<endl;
}
return ;
}
【区间筛】2017多校训练四 HDU6069 Counting Divisors的更多相关文章
- hdu6069 Counting Divisors 晒区间素数
/** 题目:hdu6069 Counting Divisors 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意:求[l,r]内所有数的k次方 ...
- 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 ...
- 2017 多校训练 1002 Balala Power!
Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2017 多校训练 1006 Function
Function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- 「2017 Multi-University Training Contest 2」2017多校训练2
1001 Is Derek lying 题目链接 HDU6045 Is Derek lying? 给出两个人选择题的回答,问得分分别为x和y是否可能.(\(1\le N \le 80000,0\le ...
- 【链表】2017多校训练三 HDU 6058 Kanade's sum
acm.hdu.edu.cn/showproblem.php?pid=6058 [题意] 给定一个排列,计算 [思路] 计算排列A中每个数的贡献,即对于每个ai,计算有ni个区间满足ai是区间中的第k ...
- 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon
http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...
- 「2017 Multi-University Training Contest 8」2017多校训练8
1009 I am your Father! (最小树形图-朱刘算法) 题目链接 HDU6141 I am your Father! 求有向图最大生成树,要求n的父节点尽量小. 我们将所有wi变为-w ...
- 「2017 Multi-University Training Contest 7」2017多校训练7
1002 Build a tree(递归) 题目链接 HDU6121 Build a tree 有一棵n个点的有根树,标号为0到n-1,i号点的父亲是\(\lfloor\frac{i-1}{k}\rf ...
随机推荐
- Outlook读取奇妙清单Wunderlist日历失败的解决办法
错误: Outlook.com日历订阅奇妙清单的日历链接时报错 This calendar wasn't updated because of a problem with the publisher ...
- Git之远程项目克隆到本地配置
远程代码克隆到本地工作区,需要进行简单的配置,用于识别身份 1.git config --global user.name [设置用户名,你的github用户名] 2.git config -- ...
- iOS html格式解析
使用TFHpple解析html https://github.com/topfunky/hpple 前期准备工作 引入静态库文件 添加库文件的 header search paths(注意,必须选中 ...
- This is such a crock of shit—From Scent of a woman
- Mr. Slade. - This is such a crock of shit! - Mr. Trask. - Please watch your language, Mr. Slade. Y ...
- COGS 1361. 树
★ 输入文件:treed.in 输出文件:treed.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] 在一个凉爽的夏夜,xth和rabbit来到花园里砍树.为啥 ...
- CodeForces - 1059D——二分/三分
题目 题目链接 简单的说,就是作一个圆包含所有的点且与x轴相切,求圆的最小半径 方法一 分析:求最小,对半径而言肯定满足单调性,很容易想到二分.我们二分半径,然后由于固定了与X轴相切,我们对于每一个点 ...
- Bézier surface(贝塞尔曲面)
Bézier surface(贝赛尔曲面) 贝塞尔曲面是一种用于计算机图形学.计算机辅助设计和有限元建模的数学样条.与贝塞尔曲线一样,贝塞尔曲面由一组控制点定义.与插值在许多方面相似,一个关键的区别是 ...
- idea java 注释模板配置
在网上找了好久,好多的文章都有一个共同的病点就是“@param注释当有多个参数时候,全部放在了一行里面”,非常不友好. 以下是我整理好的,完全按照eclipse的注释风格. !!!先看最后实现的效果图 ...
- 制作SD更新系统时和用mfgtool工具烧录时,文件如何替换?
制作SD更新系统时和用mfgtool工具烧录时,文件如何替换? 答:制作SD更新系统时,请按照需求选择不同mfgimages-myd*文件夹.每个文件夹里面有一个Manifest文件, 里面规定了ub ...
- Java垃圾回收之老年代垃圾收集器
1.Serial Old 收集器(-XX: +UseSerialOldGC, 标记-整理算法) 1.1 单线程收集,进行垃圾收集时,必须暂停所有工作线程 1.2 简单高效,Client模式下默认的老年 ...