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 ;
}

代码

UVA 10892 LCM Cardinality 数学的更多相关文章

  1. UVA 10892 - LCM Cardinality

    Problem F LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair ...

  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. UVA 11388-GCD LCM(数学)

    I I U C   O N L I N E   C  Problem D: GCD LCM Input: standard input Output: standard output The GCD ...

  6. LCM Cardinality 暴力

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

  7. UVa 10892 (GCD) LCM Cardinality

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

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

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

  9. UVa 10288 - Coupons(数学期望 + 递推)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

随机推荐

  1. hdu 2988 Dark roads

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2988 Dark roads Description Economic times these days ...

  2. Android 设计模式

    简介 项目开发中发现问题.解决问题这个过程中会出现很多问题,比如重复出现.某个问题的遗留,这些问题的本质就是设计模式.今天记录设计模式的知识点. 内容 在java以及其他的面向对象设计模式中,类与类之 ...

  3. linux 禁止指定账号ssh登陆

    1 2 3 4 vim /etc/pam.d/sshd   #在第一行添加以下代码 auth       required     pam_listfile.so item=user sense=de ...

  4. unity工具IGamesTools之批量生成帧动画

    unity工具IGamesTools批量生成帧动画,可批量的将指定文件夹下的帧动画图片自动生成对应的资源文件(Animation,AnimationController,Prefabs) unity工 ...

  5. Min Stack

    Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constan ...

  6. Android BLE API: GATT Notification not received

    When setting the value to the descriptor instead of putting descriptor.setValue(BluetoothGattDescrip ...

  7. SqlServer中Sql语句的逻辑执行顺序

    准备数据 Sql脚本如下,两张表,一张客户表Customers只包含customerid和city字段,一张订单表Orders包含orderid和customerid(关联Customers的cust ...

  8. jta.properties transactions.properties Log already in use 解决方法

    当在resin里跑多个含有atomikos控制事物的项目时,会报错,Log already in use. 解决方法: 加jta.properties或者transactions.properties ...

  9. (转)c语言学习volatile

    原文网址:http://www.cnblogs.com/chio/archive/2007/11/24/970632.html 参考网址:http://www.embedu.org/Column/Co ...

  10. iframe 传值问题

    当一个页面中插入了iframe或者由不同的框架组成(fieldset)时,这种情况下,需要处理的业务逻辑比较常见的就是数据进行交互了 1.页面中插入了iframe情况 由于页面中插入了iframe,那 ...