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

/*************************************************************************
> Author: xlc2845 > Mail: xlc2845@gmail.com
> Created Time: 2013年10月26日 星期六 10时15分23秒
************************************************************************/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#define maxn 210
#define INF 0x7fffffff
#define longlong LL
using namespace std; int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a%b);
} int lcm(int a, int b)
{
return a / gcd(a, b)*b;
} int n, a[1000000], k, ans; int main()
{
while(scanf("%d",&n) && n)
{
k = ans = 0;
for(int i = 1; i <= sqrt(n+0.1); i++)
{
if(n%i == 0)
{
a[k++] = i;
a[k++] = n/i;
}
}
if(a[k-1] == a[k-2]) //不能少
k--;
for(int i = 0; i < k; i++)
for(int j = i; j < k; j++)
if(lcm(a[i], a[j]) == n)
ans++;
printf("%d %d\n", n, ans);
}
return 0;
}

uva 10892的更多相关文章

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

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

  2. UVA 10892 - LCM Cardinality

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

  3. 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 ...

  4. UVa 10892 (GCD) LCM Cardinality

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

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

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

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

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

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

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

  8. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  9. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

随机推荐

  1. android图片切换ImageSwichter的动画切换效果

    activity_main.xml 控件的线性布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/an ...

  2. 资源汇集:nginx教程从入门到精通

    http://linux.cn/article-4279-1.html

  3. 第二篇、倾力总结40条常见的移动端Web页面问题解决方案

    1.安卓浏览器看背景图片,有些设备会模糊.   用同等比例的图片在PC机上很清楚,但是手机上很模糊,原因是什么呢? 经过研究,是devicePixelRatio作怪,因为手机分辨率太小,如果按照分辨率 ...

  4. gitignre

    1.配置语法: 以斜杠“/”开头表示目录: 以星号“*”通配多个字符: 以问号“?”通配单个字符 以方括号“[]”包含单个字符的匹配列表: 以叹号“!”表示不忽略(跟踪)匹配到的文件或目录: PLAC ...

  5. mysql配置优化测试

    http://bjlfp.blog.163.com/blog/static/77368461201211695924524/ 感觉真不错啊.观察几天看看

  6. nutch安装配置

    http://nlp.solutions.asia/?p=180 http://www.promenade.me/archives/146 环境 ubuntu 12.04 sql建表 CREATE D ...

  7. ALI OSS RequestTimeTooSkewed

    php版阿里oss sdk,请求时抛RequestTimeTooSkewed错误,说时间差距太大,搜了一下发现是服务器的时间设置问题. 我们在安装完Centos Linux操作系统之后,点击系统的时间 ...

  8. Android学习1

    Activity学习(1) 只有一个Activity 进行Toast通知 Toast是一种短小的提醒,显示一段时间就会消失,试验学习,可以通过一个Button来实现. Button reg=(Butt ...

  9. Security log is full,only administrator can log on to fix the problem(安全日志满了)

    When you login the system and see this error  “Security log on this system is full,only administrato ...

  10. (转)Qt Model/View 学习笔记 (七)——Delegate类

    Qt Model/View 学习笔记 (七) Delegate  类 概念 与MVC模式不同,model/view结构没有用于与用户交互的完全独立的组件.一般来讲, view负责把数据展示 给用户,也 ...