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
2
12
24
101101291
0
Sample Output
2 2
12 8
24 11
101101291 5
题意:给你m,求出多少对 数的LCM(a,b)=m
题解:必然是M的因子,我们对M求因子,我们知道因子特别少,我们就两层循环暴力去找对子就好了
//meek///#include<bits/stdc++.h> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include<iostream> #include<bitset> #include<vector> using namespace std ; #define mem(a) memset(a,0,sizeof(a)) #define pb push_back #define fi first #define se second #define MP make_pair typedef long long ll; const int N = 10005; const int M = 1000001; const int inf = 0x3f3f3f3f; const int MOD = 1000000007; const double eps = 0.000001; int main() { ll n;vector<ll >G; 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(int i=0;i<G.size();i++) for(int j=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; }