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 = ;
const int M = ;
const int inf = 0x3f3f3f3f;
const int MOD = ;
const double eps = 0.000001; int main() {
ll n;vector<ll >G;
while(~scanf("%lld",&n)) {
if(n == ) break;
if(n == ) {
cout<<<<" "<<<<endl;continue;
}
ll ans = ;
ll aim = n;
G.clear();
G.pb(n);G.pb();
for(ll i=;i*i<=n;i++) {
if(n%i==) {
G.pb(i);if(n/i!=i) G.pb(n/i);
}
}
sort(G.begin(),G.end());
for(int i=;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 ;
}

代码

最新文章

  1. [bzoj2653][middle] (二分 + 主席树)
  2. openssh for windows安装
  3. 使用Git将本地代码上传到GitHub
  4. [代码示例]用Fine Uploader+ASP.NET MVC实现ajax文件上传
  5. poj 2485 (kruskal算法)
  6. some links
  7. R formulas in Spark and un-nesting data in SparklyR: Nice and handy!
  8. mysql默认安装目录说明
  9. Supervisor安装与使用
  10. 权限管理系统之集成Shiro实现登录、url和页面按钮的访问控制
  11. j2ee课程设计—基于activiti的请休假系统
  12. 微信小程序(一):编写58同城页面
  13. [Vue warn]: Do not use built-in or reserved HTML elements as component id: header
  14. [VS2013]发布网站时修改配置文件
  15. 树莓派上启动nfs server
  16. 数学图形(1.48)Cranioid curve头颅线
  17. 关于Eclipse如何加入Gradle文件与Android Studio两个平台一起开发,工作目录不发生变化
  18. ubuntu13.04 搭建 Nginx + PHP + PHP-FPM + Mysql (lnmp) 环境
  19. Python实现的常用排序方法
  20. 常用JS、jquery 命令(不断更新中)

热门文章

  1. bash: 避免命令重复执行的简单脚本
  2. flask环境配置
  3. git用法
  4. 触发器(trigger)的作用???
  5. 基于PBOC电子钱包的圈存过程详解
  6. 向Array中添加选择排序
  7. Why Every Professional Should Consider Blogging
  8. backgroundworker的使用问题
  9. 使用javac命令编译java文件。
  10. 【数据结构】通用的最小堆(最大堆)D-ary Heap