Uva 10892 - LCM Cardinality 解题报告(因式分解)
来源:互联网 发布:yii2源码下载 编辑:程序博客网 时间:2024/06/09 18:30
Problem F
LCM Cardinality
Input: Standard Input
Output: Standard Output
Time Limit: 2 Seconds
A pair of numbers has a unique LCM but a single number can be the LCM of more than one possible pairs. For example 12 is the LCM of (1, 12), (2, 12), (3,4) etc. For a given positive integer N, the number of different integer pairs with LCM is equal to N can be called the LCM cardinality of that number N. In this problem your job is to find out the LCM cardinality of a number.
Input
The input file contains at most 101 lines of inputs. Each line contains an integer N (0<N<=2*109). Input is terminated by a line containing a single zero. This line should not be processed.
Output
For each line of input except the last one produce one line of output. This line contains two integers N and C. Here N is the input number and C is its cardinality. These two numbers are separated by a single space.
Sample Input Output for Sample Input
2
12
24
101101291
0
2 2
12 8
24 11
101101291 5
Problem setter: Shahriar Manzoor
Special Thanks: Derek Kisman
#include <cstdio>#include <algorithm>#include <cstring>using namespace std;void work(int n){ int nn=n; int ans=1; for(int i=2;i*i<=n;i++) if(n%i==0) { int t=0; while(n%i==0) n/=i,t++; ans*=(t*2+1); } if(n>1) ans*=3; ans-=1; ans/=2; ans+=1; printf("%d %d\n", nn, ans);}int main(){ int n; while(~scanf("%d",&n) && n) work(n);}
- Uva 10892 - LCM Cardinality 解题报告(因式分解)
- UVa 10892 - LCM Cardinality (因式分解 组合数学)
- Uva 10791 - Minimum Sum LCM 解题报告(因式分解)
- LCM Cardinality(UVA 10892)
- UVa:10892 LCM Cardinality
- UVA 10892-LCM Cardinality
- UVa 10892 - LCM Cardinality
- UVA 10892 - LCM Cardinality
- UVA 10892 LCM Cardinality
- uva 10892 LCM Cardinality
- UVa-10892 LCM Cardinality
- UVA-10892 LCM Cardinality
- uva 10892 - LCM Cardinality(数论)
- UVA 10892 - LCM Cardinality(数论)
- UVA - 10892 LCM Cardinality (枚举因子)
- POJ 2429 GCD & LCM Inverse 解题报告(大数因式分解)
- UVA 10892 LCM Cardinality(数论 质因数分解)
- UVa 10892 LCM Cardinality (分解质因数+数学)
- 支持向量机通俗导论(理解SVM的三层境界)
- 德国:这就是中国对克里米亚危机高兴的原因
- JBOSS EAP 6 系列二 Oracle数据源的配置—认识模块的使用
- C++二叉堆的实现
- 【爱上cocos2d-x之九】cocos2d-x坐标系与anchorPoint锚点
- Uva 10892 - LCM Cardinality 解题报告(因式分解)
- mfc LISTbox
- Java byte数组与十六进制字符串互转
- poj1861 Network
- F5公司负载均衡技术
- Core Animation之简单使用CALayer
- kettle使用手册
- 关于c语言的总结
- IOS 开发之UIApplicationDelegate详解