A pair of numbers have a unique LCM but a single number can is the LCM of more than one possible
Pairs. For example are the LCM of (1, 2), (3,4) etc. For a given positive integer N, the
Number of di?erent integer pairs with LCM are equal to N can being called the LCM cardinality of that
Number N. In this problem your job was to nd out the LCM cardinality of a number.
Input
The input Le 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 is should not being processed.
Output
For each line of input except the last one produce one line of output. This line contains the integers
N and C. Here N is the input number and C are its cardinality. These numbers is separated by a
Single space.
Sample Input
2
12
24
101101291
0
Sample Output
2 2
12 8
24 11
101101291 5
Test Instructions : give you m, find out how many logarithm of the LCM (A, b) =m
The most essential factor is M, we have a factor of M, we know the factor is very small, we will be two layers of cyclic violence to find the pair.
//Meek///#include <bits/stdc++.h>#include <cstdio>#include<cmath>#include<cstring>#include<algorithm>#include<iostream>#include<bitset>#include<vector>using namespacestd;#defineMem (a) memset (A,0,sizeof (a))#definePB Push_back#defineFi first#defineSe Second#defineMP Make_pairtypedefLong Longll;Const intN =10005;Const intM =1000001;Const intINF =0x3f3f3f3f;Const intMOD =1000000007;Const DoubleEPS =0.000001;intMain () {ll n;vector<ll >F; while(~SCANF ("%lld",&N)) {if(n = =0) Break; if(n = =1) {cout<<1<<" "<<1<<endl;Continue; } ll ans=0; ll Aim=N; G.clear (); G.PB (n); G.PB (1); for(LL i=2; i*i<=n;i++) { if(n%i==0) {G.PB (i);if(n/i!=i) G.PB (n/i); }} sort (G.begin (), G.end ()); for(intI=0; I<g.size (); i++) for(intJ=i;j<g.size (); j + +) {ll a=G[i]; LL b=G[j]; if(A*B/__GCD (A, b) = =aim) ans++;//,cout<<a<< "" <<b<<endl;} cout<<aim<<" "<<ans<<Endl; } return 0;}Code
UVA 10892 LCM Cardinality Math