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

Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1604    Accepted Submission(s): 592 Problem Description In mathematics, the function d(n) denotes the number of divisors of p…
Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 3170    Accepted Submission(s): 1184 Problem Description In mathematics, the function d(n) denotes the number of divisors of…
Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) 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,…
Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 2599    Accepted Submission(s): 959 Problem Description In mathematics, the function d(n) denotes the number of divisors of p…
http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 思路: 根据唯一分解定理,$n={a_{1}}^{p1}*{a2_{}}^{p2}...*{a_{m}}^{pm}$,那么n的因子数就是 n的k次方也是一样的,也就是p前面乘个k就可以了. 先打个1e6范围的素数表,然后枚举每个素数,在[ l , r ]寻找该素数的倍数,将其分解质因数. 到最后如果一个数没有变成1,那就说明这个数是大于1e6的质数.(它就只有0和1两种选择) #include<…
题目链接 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 followin…
题意:给定 l,r,k,让你求,其中 l <= r <= 1e12, r-l <= 1e6, k <= 1e7. 析:首先这个题肯定不能暴力,但是给定的区间较小,可以考虑筛选,n = p1^c1*p2^c2*....*pn^cn,那么 d(n) = (c1+1) * (c2+1) * ...*(cn+1). d(n^k) =  (kc1+1) * (kc2+1) * ...*(kcn+1),这样的话,我们只要求出每个数的素因子的个数就好,直接算还是不行,只能先把1-sqrt(n)之…
题意:...就题面一句话 思路:比赛一看公式,就想到要用到约数个数定理 约数个数定理就是: 对于一个大于1正整数n可以分解质因数: 则n的正约数的个数就是 对于n^k其实就是每个因子的个数乘了一个K 然后现在就变成了求每个数的每个质因子有多少个,但是比赛的时候只想到sqrt(n)的分解方法,总复杂度爆炸,就一直没过去,然后赛后看官方题解感觉好妙啊! 通过类似素数筛法的方式,把L - R的质因子给分解,就可以在O(nlogn)的时间之内把所以的数给筛出来. 代码: /** @xigua */ #i…
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> #i…
比赛的时候把公式扣出来了,,但是没有想到用筛法算公因子,,默默学习一下.. 题解:设n=p1^(c1)p2^{c2}...pm^{cm},n=p​1^​c​1*​​​​p​2​^c​2​​​​...p​m​^c​m​​​​,则d(n^k)=(k*c1+1)(k*c2+1)...(k*cm+1)d(n​k​​)=(kc​1​​+1)(kc​2​​+1)...(kc​m​​+1).然后由于l,r的值很大,但是l-r的范围还是可以接受的,所以我们用一个偏移数组 来存l<=n<=r数的d(n).然后就…
地址:http://acm.split.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): 1235    Accepted Submission(s): 433 Problem Description In mathem…
/** 题目:hdu6069 Counting Divisors 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意:求[l,r]内所有数的k次方的约数个数之和. 思路: 用(1+e1)*(1+e2)*...*(1+en)的公式计算约数个数. 素数筛出[l,r]内的素因子,然后直接计算结果.(一开始我用vector存起来,之后再处理,结果超时, 时间卡的很紧的时候,vector也会很占用时间.) */ #include<iostream>…
传送门:hdu 5862 Counting Intersections 题意:对于平行于坐标轴的n条线段,求两两相交的线段对有多少个,包括十,T型 官方题解:由于数据限制,只有竖向与横向的线段才会产生交点,所以先对横向线段按x端点排序,每次加入一个线段,将其对应的y坐标位置+1,当出现一个竖向线段时,查询它的两个y端点之间的和即为交点个数. 注意点:对x坐标排序是对所有线段端点排序:因为可能出现 “  1-1  “ 这样的情况,所以对于横着的线段,需要进行首尾x坐标处理:我的方法是对于x坐标,先…
HDU 5862 Counting Intersections(离散化+树状数组) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Description Given some segments which are paralleled to the coordinate axis. You need to count the number of their intersection. The input data guarant…
Counting Divisors 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…
DIVCNT2 - Counting Divisors (square) DIVCNT3 - Counting Divisors (cube) 杜教筛 [学习笔记]杜教筛 (其实不算是杜教筛,类似杜教筛的复杂度分析而已) 你要大力推式子: 把约数个数代换了 把2^质因子个数 代换了 构造出卷积,然后大于n^(2/3)还要搞出约数个数的式子和无完全平方数的个数的容斥... .... 然后恭喜你,spoj上过不去... bzoj能过: #include<bits/stdc++.h> #define…
hdu 6184 Counting Stars(三元环计数) 题意: 给一张n个点m条边的无向图,问有多少个\(A-structure\) 其中\(A-structure\)满足\(V=(A,B,C,D)\) && \(E=(AB,BC,CD,DA,AC)\) 显然\(A-structure\)是由两个有公共边的三元环构成的 \(1 <=n <= 1e5\) \(1 <= m <= min(2e5,n*(n-1)/2)\) 思路: 三元环计数 做法1. ①统计每个点…
传送门:Hdu 5862 Counting Intersections 题意:有n条线段,每一条线段都是平行于x轴或者y轴,问有多少个交点 分析: 基本的操作流程是:先将所有的线段按照横树坐标x按小的优先排序,注意是所有的线段 :(这里是将线段都去掉只保留两个端点) 然后从左到右的顺序经行扫描,遇到横的线段,如果是左端点对应的 yi 便++ , 若是右端点对应的y1便--:  遇到竖直的线段,便统计区间[y1,y2] 的数 , 看到这了是不是有点东西了呢? 如果我是按照x排序的话,两线段若想相交…
DIVCNT2 - Counting Divisors (square) #sub-linear #dirichlet-generating-function Let \sigma_0(n)σ​0​​(n) be the number of positive divisors of nn. For example, \sigma_0(1) = 1σ​0​​(1)=1, \sigma_0(2) = 2σ​0​​(2)=2 and \sigma_0(6) = 4σ​0​​(6)=4. LetS_2(…
题目 vjudge URL:Counting Divisors (square) Let σ0(n)\sigma_0(n)σ0​(n) be the number of positive divisors of nnn. For example, σ0(1)=1\sigma_0(1) = 1σ0​(1)=1, σ0(2)=2\sigma_0(2) = 2σ0​(2)=2 and σ0(6)=4\sigma_0(6) = 4σ0​(6)=4. Let S2(n)=∑i=1nσ0(i2).S_2(n…
设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个…
Counting Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1885    Accepted Submission(s): 946 Problem Description Your input is a series of rectangles, one per line. Each rectangle is sp…
Counting Intersections 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Description Given some segments which are paralleled to the coordinate axis. You need to count the number of their intersection. The input data guarantee that no two se…
Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 539    Accepted Submission(s): 204 Problem Description A clique is a complete graph, in which there is an edge between every pair…
题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Counting Intersections Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 Given some segments which are paralleled to the coordinate axis. You need to coun…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069 题目意思:首先解释一下d[n]这个函数表示n有多少个因子,百度一下可以知道这个函数是一个非完全积性函数,d[n]=d[i]*d[j]当且仅当i*j=n,且i和j互质,现在求一个[l,r]区间的所有数d[i^k]的和. 思路:比赛场上知道xjb推出了题目给的这个公式d(n​^k​​)=(kc​1​​+1)(kc​2​​+1)...(kc​m​​+1),还是很容易推了的,可能百度也可以找到吧,还是…
版权声明:欢迎关注我的博客.本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/25471349 Problem A : Counting Squares pid=1264" rel="nofollow">From:HDU, 1264 Problem Description Your input is a series of rectangles, one per lin…
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>…
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6069 [Description] 定义d(i)为数字i的因子个数; 求∑rld(ik) 其中l,r<=1012且r−l<=106 [Solution] 如果把一个数x质因数分解成p1a1∗p2a2∗...∗pnan 的形式; 可知数字x的因子个数为 (a1+1)∗(a2+1)∗...∗(an+1) 因为i还有k次方; 所以答案就是 (a1∗k+1)∗(a2∗k+1)∗...∗(an∗k+1)…
Counting Cliques HDU - 5952 OJ-ID: hdu-5952 author:Caution_X date of submission:20191110 tags:dfs,graph description modelling:给定点数,边数,问包含有x个点的完全图种类数 major steps to solve it:(1)选择一个点作为起点,记录该起点的所有连通点,dfs(该点)此时完全图有两个点(2)遍历(1)中选定点的连通点,若构成完全图,则dfs(能够与(1)的…