http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31675#problem/E

暴力

// File Name: uva10892.cpp
// Author: bo_jwolf
// Created Time: 2013年09月16日 星期一 22:32:26 #include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime> using namespace std; vector<int> Q ;
long long n ; long long gcd( long long a , long long b )
{
return b == 0 ? a : gcd( b , a % b ) ;
} long long lcm( long long a , long long b )
{
return ( 1LL*a * b ) / gcd( a , b ) ;
} int main()
{
while( scanf( "%lld" , &n ) != EOF )
{
if( n == 0 )
break ;
Q.clear() ;
for( long long i = 1 ; i <= sqrt( n ) ; ++i )
{
if( n % i == 0 )
{
if( n / i != i )
{
Q.push_back( n / i ) ;
Q.push_back( i ) ;
}
else
{
Q.push_back( i ) ;
}
}
}
long long len = Q.size() ;
long long ans = 1 ;
for( long long i = 0 ; i < len ; ++i )
{
for( long long j = i + 1 ; j < len ; ++j )
{
if( lcm( Q[ i ] , Q[ j ] ) == n )
ans++ ;
}
}
printf( "%lld %lld\n" , n , ans ) ;
}
return 0;
}

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 数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

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

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

  4. LCM Cardinality 暴力

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

  5. UVa 10892 (GCD) LCM Cardinality

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

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

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

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

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

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

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

  9. UVA 11076 Add Again 计算对答案的贡献+组合数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

随机推荐

  1. 动态Script标签 解决跨域问题

     动态Script 解决跨域问题 1.动态创建scriptcreateScript : function(src){ var varScript = document.createElement(&q ...

  2. NET Core 的 Views

    NET Core 十种方式扩展你的 Views 原文地址:http://asp.net-hacker.rocks/2016/02/18/extending-razor-views.html作者:Jür ...

  3. ODI中删除数据的处理

    ODI中删除数据的处理 一.前提知识:数据从源数据库向数据仓库抽取时,一般采用以下几种方式: 全抽取模式如果表的数据量较小,则可以采取全表抽取方式,以TRUNCATE/INSERT方式进行数据抽取. ...

  4. poj 3323 Matrix Power Series (矩阵乘法 非递归形式)

    为了搞自动机+矩阵的题目,特来学习矩阵快速幂..........非递归形式的求Sum(A+A^2+...+A^k)不是很懂,继续弄懂................不过代码简洁明了很多,亮神很给力 # ...

  5. 练习一下linux中的list函数。

    所有的list函数见 include/linux/list.h 自己从 include/linux/list.h 拷贝了一些函数到自己的list.c中, 然后练习了一下. 没有别的目的,就是想熟练一下 ...

  6. saiku中过滤窗口优化及隐藏异常报错

    问题一:当取消自动查询后,点击该维度应弹出过滤条件窗口,实际无反应,只有执行一次查询后再点击该维度,才能弹出过滤条件窗口 解决办法:打开WorkspaceDropZone.js文件,找到selecti ...

  7. Java操作mongoDB2.6的常见API使用方法

    对于mongoDB而言,学习方式和学习关系型数据库差不太多 開始都是学习怎样insert.find.update.remove,然后就是分页.排序.索引,再接着就是主从复制.副本集.分片等等 最后就是 ...

  8. xcode - 移动手势

    #import "ViewController.h" @interface ViewController () /** 创建一个UIView */ @property(nonato ...

  9. 利用Telnet来模拟Http请求 有GET和POST两种

    利用Telnet来模拟Http请求---访问百度.       1.打开"运行"->cmd进入命令环境:       2.输入"telnet www.baidu.c ...

  10. 你应该知道CSS选择器技巧

    什么是:before和:after? 该如何使用他们? :before是css中的一种伪元素,可用于在某个元素之前插入某些内容. :after是css中的一种伪元素,可用于在某个元素之后插入某些内容. ...