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. Python核心编程笔记---- print@2

    print 的输出从定向问题 print 可以用’>>‘来重定向输出,下面是例子 f = open('D:/python.txt','w+') print >> f," ...

  2. HBase源代码分析

    http://www.docin.com/p-647062205.html http://blog.csdn.net/luyee2010/article/category/1285622 http:/ ...

  3. tomcat path配置

    <pre name="code" class="html">demo:/root# curl http://192.168.32.42:8082/a ...

  4. GDOI2015酱油记

    GDOI2015酱油记 今年的GDOI在北江举行,比赛前一天坐了5小时的车才到,幸好忍住了,没有在车上吐. Day 1 刚到电教楼,看完考室后,第一时间找厕所,结果发现只有一楼有厕所,坑爹我的考室在三 ...

  5. 【百度地图API】获取行政区域的边界

    );map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}));map.enableScroll ...

  6. 从零开始nodejs系列文章

    http://blog.fens.me/series-nodejs/ 从基础的node安装到npm配置,从express到jade,还有mongoDB.是一个很好的node教程

  7. tomcat中开启的对SSL(https)的支持

    打开conf/server.xml会发现有下面一段配置被注释着: <!-- <Connector port="8443" protocol="HTTP/1.1 ...

  8. 认识jeecms开源项目

    1. JEECMS源代码基本结构及相关技术简介: 参考:http://blog.csdn.net/caozhenyu/article/details/47005623

  9. sql 练习(3)

    1.打印九九乘法表 ) ,exp)) A, ,exp))B, ,exp))C, ,exp))D, ,exp))E, ,exp))F, ,exp))G, ,exp))H, ,exp))I from ( ...

  10. Convert Binary Search Tree (BST) to Sorted Doubly-Linked List

    (http://leetcode.com/2010/11/convert-binary-search-tree-bst-to.html) Convert a BST to a sorted circu ...