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.

<!--[if !supportEmptyParas]--> <!--[endif]-->

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.

<!--[if !supportEmptyParas]--> <!--[endif]-->

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.

<!--[if !supportEmptyParas]--> <!--[endif]-->

Sample Input                             Output for Sample Input

2
12
24
101101291
0

2  2

12  8

24  11

101101291  5

#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std ;
typedef long long LL ;
const int M= ;
bool isprime[M+] ;
int prime[M] ,id;
void make_prime(){
id= ;
memset(isprime,,sizeof(isprime)) ;
for(int i=;i<=M;i++){
if(!isprime[i])
prime[++id]=i ;
for(int j=;j<=id&&prime[j]*i<=M;j++){
isprime[i*prime[j]]= ;
if(i%prime[j]==)
break ;
}
}
}
LL gao(LL x){
LL sum ;
LL ans= ;
for(int i=;i<=id&&prime[i]*prime[i]<=x;i++){
if(x%prime[i]==){
sum= ;
while(x%prime[i]==){
sum++ ;
x/=prime[i] ;
}
ans=ans*(sum+sum+) ;
}
if(x==)
break ;
}
if(x!=)
ans*= ;
return (ans+)>> ;
}
int main(){
LL x ;
make_prime() ;
while(cin>>x&&x){
cout<<x<<" "<<gao(x)<<endl ;
}
return ;
}

UVA 10892 - LCM Cardinality的更多相关文章

  1. UVA 10892 LCM Cardinality 数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

  2. UVA 10892 LCM Cardinality(数论 质因数分解)

    LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair of number ...

  3. UVA 10892 - LCM Cardinality(数学题)

    题目链接 写写,就ok了. #include <cstdio> #include <cstring> #include <string> #include < ...

  4. Uva 10892 LCM Cardinality (数论/暴力)

    题意:给出数n,求有多少组A,B的最小公约数为n; 思路:3000ms,直接暴力寻找,找到所有能把n整除的数 pi, 枚举所有pi 代码: #include <iostream> #inc ...

  5. LCM Cardinality 暴力

    LCM Cardinality Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit St ...

  6. UVa 10892 (GCD) LCM Cardinality

    我一直相信这道题有十分巧妙的解法的,去搜了好多题解发现有的太过玄妙不能领会. 最简单的就是枚举n的所有约数,然后二重循环找lcm(a, b) = n的个数 #include <cstdio> ...

  7. LCM Cardinality UVA - 10892(算术基本定理)

    这题就是 LightOJ - 1236 解析去看这个把https://www.cnblogs.com/WTSRUVF/p/9185140.html 贴代码了: #include <iostrea ...

  8. uva 10892

    试了一下纯暴力  结果过了 无话可说  应该有更好的方法...... /**************************************************************** ...

  9. LCM Cardinality

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31675#problem/E 暴力 // File Name: uva10892.cpp ...

随机推荐

  1. Window下SVN命令的使用总结

    1 地址:http://subversion.apache.org/packages.html#windows 找到windows下的svn客户端工具.选择Win32Svn 进行安装. 一般环境变量会 ...

  2. mysql frm的恢复,data里只有frm文件的恢复

    mysql frm的恢复,data里只有frm文件的恢复 mysql frm的恢复,data里只有frm文件的恢复,换了系统,装了windows2003,重装最新5.4版的mysql,把原来的一个数据 ...

  3. Ansible常用模块及API

    Ansible安装 安装EPEL作为安装Ansible的yum源(CentOS6.4): rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel ...

  4. 给windows的VM更换网卡到VMNET3从E1000

    1. Login to vCenter via vSphere client. go to the vm 2. create a 1G new disk(SCSI 1:2) for the VM te ...

  5. WINDOWS黑客基础(3):注入代码

    有使用过外挂的朋友应该知道,我们在玩游戏的时候,有很多辅助功能给你使用,比如吃药,使用物品等功能,这个时候我们就是使用注入代码的技术,简单的来将就是我们让另外一个进程去执行我们想让它执行的代码,这中间 ...

  6. ASP.NET内置对象详解

    ASP.NET的内置对象介绍 1.Response 2.Request 3.Server 4.Application 5.Session 6.Cookie Request对象主要是让服务器取得客户端浏 ...

  7. [dts]Device Tree格式解析

    转自:http://blog.csdn.net/airk000/article/details/21345159 目录: 1. 作用 2. 基本数据格式 3. 一些基本概念 4. 工作方式 a. 地址 ...

  8. spark transformation与action操作函数

    一.Transformation map(func) 返回一个新的分布式数据集,由每个原元素经过函数处理后的新元素组成 filter(func) 返回一个新的数据集,经过fun函数处理后返回值为tru ...

  9. PLSQL_基础系列01_正则表达REGEXP_LIKE / SUBSTR / INSTR / REPLACE(案例)

    2014-11-30 Created By BaoXinjian

  10. 【初识】KMP算法入门(转)

    感觉写的很好,尤其是底下的公式,易懂,链接:http://www.cnblogs.com/mypride/p/4950245.html 举个例子 模式串S:a s d a s d a s d f a  ...