hdu 1299 数论 分解素因子
2014-04-30 21:19
357 查看
题意:求1、1/x+1/y=1/z 给定z 求x,y的个数 zsd: 1: 要知道这个素数的因子的范围 范围为2——sqrt(n); 2:
带入方程得:x = n * n / k + n ;
现在就变成了求x的值。又因为n一定大于k,所以转换成求n * n的分解数;
因为n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en
sum ( n)= ( 1 + e1 ) * ( 1 +e2 ) * .........* ( 1 +en );
sum (n * n) = ( 1 + e1 ) * (1 + e2 ) *......* ( 1 + en ) ;
#include<iostream> #include<cstring> using namespace std; # define N 40003 int a ; int main() { int i,j; memset(a,0,sizeof(a)); for(i=2;i<N;i++) if(a[i]==0) { for(j=i+i;j<N;j+=i) a[j]=1; } int t; int n; cin>>t; int T=1; for(T=1;T<=t;T++) { cin>>n; int sum=1; for(i=2;i<=N;i++) { if(a[i]) continue; if(n%i!=0) continue; if(n==1) break; int c=0; while(n%i==0) { n=n/i; c++; } if(c>0) sum*=(2*c+1); } if(n!=1) sum*=3; cout<<"Scenario #"<<T<<":"<<endl; cout<<sum/2+1<<endl<<endl; } return 0; }
相关文章推荐
- [数论]HDU 1452 Happy 2004 素因子分解+快速幂模+乘法逆元
- hdu1299 素因子分解
- HDU 1299分解素因子--唯一分解定理
- hdu 1299 Diophantus of Alexandria(数论(因子个数和))
- hdu 1454 Happy 2004(数论,分解因子,乘法逆元,快速幂取模)
- HDU-1299 Diophantus of Alexandria(数论:因子数)
- HDU 1299(数论,求n的素因子个数)
- HDU-1299 Diophantus of Alexandria 素因子分解
- hdu-1299 Diophantus of Alexandria(分解素因子)
- HDU-4279 Number 欧拉函数,因子分解综合
- hdu1299 Diophantus of Alexandria---素因子分解
- hdu 1299 Diophantus of Alexandria (数论)
- 数论二1010大整数的质因子分解(此题模板得记)
- hdu 5778 abs(分解质因子,枚举平方数,数论)
- hdu 1695 综合数论 欧拉函数 分解质因子 容斥原理 打印素数表 帅呆了的一个题目 详解
- hdoj 1492 The number of divisors(约数) about Humble Numbers 【数论】【质因子分解 求和】
- HDU 4961 Boring Sum(分解因子)
- HDU 1299 Diophantus of Alexandria 求因子个数
- HDU 6069 Counting Divisors(唯一分解定理+因子数)
- 数论 素数筛选法与整数的素因子分解