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

/*************************************************************************
> 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操作通讯录的联系人

    界面配置文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     and ...

  2. android手机中图片的拖拉及浏览功能

    配置文件 activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andro ...

  3. .NET微信支付(H5仅限公众号支付)

    闲来无事,恰好有一个要用微信公众平台支付的功能,研究来研究去,就是要细心和多看腾讯提供的文档.当然有几个坑是很有必要说明一下的 公众号支付,这里统一叫H5支付,以下都是. 在做H5支付的时候,第一步就 ...

  4. 那万恶的ssh真是麻烦

    设置为允许某组远程ssh ,key也放入相应的服务器了,死活提示,Permission denied (publickey). 而偏偏另外的用户相同的配置却又可以,这里找到答案,原来是跟目录的权限有关 ...

  5. 三星智能手机如何运用Smart Switch?

    1.Smart Switch是指? 使用前注意事项: 将两部智能手机的距离保持在50cm以内 两部智能手机都下载相同的最新版本Smart Switch 确认可支持的机器参考应用程序说明 不受干扰的安静 ...

  6. 一个简单的Makefile的编写【用自己的话,解释清楚这些】

    用自己的话,解释清楚这些~ Makefile是程序员编写出来指导编译器编译程序源码为目标文件(可执行文件,或链接库) 这里只写一个简单的Makefile 作为例子 其需求如下: frank@ubunt ...

  7. 重建Mac系统的文件打开方式

    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Ver ...

  8. iOS开发——打包ipa

    首先,保证设备证书和配置文件的正确,Xcode上登陆好自己公司的账号Apple ID 1.选中运行模拟器的位置为硬件设备 2.点击导航栏上的[Product]——[Archive]后编译后弹出如下界面 ...

  9. block回调具体例子

    //main.m ////  main.m//  回调////  Created by hehe on 15/9/10.//  Copyright (c) 2015年 wang.hehe. All r ...

  10. In-App-Purcharse 官方原文摘要笔记

    这并不是一篇关于 In-App-Purcharse 的专业深入分析文章,只是在初次浏览有关IAP官方文档后记录的一些需要注意的地方,就像是课堂笔记. 因为这是原版.并且涉及到支付的内容,所以就不翻译, ...