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的更多相关文章

  1. hdu6069 Counting Divisors 晒区间素数

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

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

  3. 2017 多校训练 1002 Balala Power!

    Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  4. 2017 多校训练 1006 Function

    Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  5. 「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 ...

  6. 【链表】2017多校训练三 HDU 6058 Kanade's sum

    acm.hdu.edu.cn/showproblem.php?pid=6058 [题意] 给定一个排列,计算 [思路] 计算排列A中每个数的贡献,即对于每个ai,计算有ni个区间满足ai是区间中的第k ...

  7. 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon

    http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...

  8. 「2017 Multi-University Training Contest 8」2017多校训练8

    1009 I am your Father! (最小树形图-朱刘算法) 题目链接 HDU6141 I am your Father! 求有向图最大生成树,要求n的父节点尽量小. 我们将所有wi变为-w ...

  9. 「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 ...

随机推荐

  1. gbk编码文件传输json实例

    cline.php <?php $str='此地无银三百两'; $str = iconv('gbk', 'utf-8', $str); //Json只支持utf-8编码,如果不进行转码的话,服务 ...

  2. html到计时特效(直接代码)

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...

  3. 013、BOM对象的应用

    BOM结构图如下: DOM结构图如下: BOM和DOM BOM,Bowser Object Model浏览器对象模型.提供了访问和操作浏览器各组件的途径或方法. 比如:Navigator对象:浏览器的 ...

  4. 生成器的send方法

    send 和next区别 next:唤醒并继续执行 send:唤醒并继续执行 发送信息到生成器内部. def fib(max): n,a,b = 0,0,1 while n < max: msg ...

  5. webapi参数处理get过个参数

    // GET api/values/5 [HttpGet("{logInName}/{pwd}/{orgId}")] public LogInOutPut Get(string l ...

  6. 第一周作业javaee strainmap

  7. PE基础1

    PE文件概述 文件格式 .png ..mp4..gif..dll等等,这些文件都具有不同格式 不能随意修改这些文件,否则将无法打开 PE文件(可执行文件) 学习PE文件目标 掌握PE文件就掌握wino ...

  8. PHP安全之 register_globals

    一.register_globals = Off 和 register_globals = On的区别 register_globals是php.ini里的一个配置,这个配置影响到php如何接收传递过 ...

  9. Navicat连不上MySQL的解决办法

    USE mysql; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{your password}'; ...

  10. faster rcnn训练过程讲解

    http://blog.csdn.net/u014696921/article/details/60321425