hdu 6069 Counting Divisors(2017多校第四场)

来源:互联网 发布:linux mount cifs 编辑:程序博客网 时间:2024/06/06 02:55

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069

Counting Divisors

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 3282    Accepted Submission(s): 1221


Problem Description
In mathematics, the function d(n) denotes the number of divisors of positive integer n.

For example, d(12)=6 because 1,2,3,4,6,12 are all 12's divisors.

In this problem, given l,r and k, your task is to calculate the following thing :

(i=lrd(ik))mod998244353

 

Input
The first line of the input contains an integer T(1T15), denoting the number of test cases.

In each test case, there are 3 integers l,r,k(1lr1012,rl106,1k107).
 

Output
For each test case, print a single line containing an integer, denoting the answer.
 

Sample Input
31 5 11 10 21 100 3
 

Sample Output
10482302
 

Source
2017 Multi-University Training Contest - Team 4
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6143 6142 6141 6140 6139 
 

Statistic | Submit | Discuss | Note

解析:n = k1^x1*k2^x2*........kn^xn, (k1, k2, k3.......kn是质数, x1, x2,z3.......xn是幂),那么一个数的因子数等于 ans = (x1+1)*(x2+1)*(x3+1)*......*(xn+1)。知道这样还不够,这样暴力写会TLE,咱还需要用到区间筛选,对,就是这样,打素数表时10^5会WA,需要打10^6的表,WA的心疼,,

代码:

#include<bits/stdc++.h>using namespace std;typedef long long LL;const int N = 1000006;const LL p = 998244353;int pri[N], ispri[N], len;LL a[1000009], num[1000009];void init(){    memset(ispri, 0, sizeof(ispri));    len = 0;    for(int i = 2; i <= 1000000; i++)    {        if(ispri[i]) continue;        pri[len++] = i;        for(int j = i*2; j <= 1000000; j += i) ispri[j] = 1;    }}int main(){    init();    LL l, r, k;    int t;    scanf("%d", &t);    while(t--)    {        scanf("%lld%lld%lld", &l, &r, &k);        for(int i = 0; i <= r - l; i++) a[i] = l+i, num[i] = 1;        for(int i = 0; i < len; i++)        {            LL s = l/pri[i]*pri[i];            if(s != l) s += pri[i];            for(LL j = s; j <= r; j += pri[i])            {                LL w = 0;                while(a[j-l] % pri[i] == 0) w++, a[j-l] /= pri[i];                num[j-l] = num[j-l] * ((1LL*w*k+1) % p) % p;            }        }        LL ans = 0;        for(int i = 0; i <= r-l; i++) if(a[i] != 1) num[i] = (num[i] * (k + 1)) % p;        for(int i = 0; i <= r-l; i++) ans = (ans + num[i]) % p;        printf("%lld\n", ans);    }    return 0;}



原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 飞机票不能退票不能改签怎么办 深圳航空买机票姓名错了怎么办 大众cc打不着火怎么办 手上扎了仙人掌刺怎么办 pscs5界面字体太小怎么办 儿童做飞机没带户口本怎么办 黑户口想做飞机怎么办 宝宝坐飞机忘记带证件怎么办 值机柜台关闭了怎么办 值机迟到几分钟怎么办 婴儿坐飞机没带证件怎么办 飞机票买了一天降价1000怎么办 社保卡磁性没了怎么办 社保卡民族错了怎么办 坐飞机婴儿出生证明没带怎么办 手提行李超过5kg怎么办 随身行李超过5kg怎么办 南航机票填错身份证怎么办 两岁宝宝坐着驼背怎么办 两岁的宝宝坐晕车怎么办 在机场丢东西了怎么办 孩子放学不按时回家怎么办?转 右腿比左腿粗2cm怎么办 八个月宝宝小腿弯怎么办 南航航班取消了怎么办 高铁不能送老人怎么办 小孩买火车票没有身份证怎么办 断奶后孩子瘦了怎么办 两岁宝宝坐飞机哭闹怎么办 八个月宝宝坐飞机哭闹怎么办 六岁儿童发烧39度怎么办 孩子坐飞机没带证件怎么办 带孩子坐飞机需要什么证件怎么办 婴儿乘飞机没带证件怎么办 吃了轮状发烧怎么办 儿童票比打折票贵怎么办 订机票订错了怎么办 如果飞机不支持婴儿票怎么办 报志愿登不上去怎么办 微单自拍是反的怎么办 蜡笔弄到桌子上怎么办