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. Nginx 拒绝指定IP访问

    来源 : http://www.ttlsa.com/nginx/nginx-deny-ip-access/   闲来无事,登陆服务器,发现有个IP不断的猜测路径.试图往服务器上传文件(木马).于是查看 ...

  2. function(ev) //括号里的ev是什么东西,什么意思?

    事件对象: 楼上的不要误导新人 ev是我们获取事件详细信息的event是IE的写法 大多数人是写window.event 其实区别也差不多 好像window.event更安全些 我也不记得了 火狐呢 ...

  3. python 连接数据库-设置oracle ,mysql 中文字符问题

    import cx_Oracle import MySQLdb def conn_oracle(): cnn = cx_Oracle.connect('用户名','密码','ip:端口号/数据库') ...

  4. c语言 选择排序

    选择排序 //    int array[] = {3, 2, 6, 9, 8, 5, 7, 1, 4}; //    int count = sizeof(array) / sizeof(array ...

  5. MVC4,MVC3,VS2012+ entity framework Migration from Sqlserver to Mysql

    在开发的初期个人认为因VS与Sqlserver的配合很默契,即可以方便的实现Code First,又可以使用SqlServer Manager很漂亮的进行建模与变更,也许是个人的使用习惯MS的界面做的 ...

  6. 限定只能处理"A仓"和"B仓"入库

    应用 Oracle Inventory 层 Level Function 函数名 Funcgtion Name INV_INVTTMTX_MISC 表单名 Form Name INVTTMTX 说明 ...

  7. ExecuteScalar

    ExecuteScalar运行查询,并返回查询所返回的结果集中第一行的第一列或空引用(假设结果集为空).忽略其它列或行. 使用 ExecuteScalar 方法从数据库中检索单个值. 由于不用创建行集 ...

  8. Fix Some bytes have been replaced with the Unicode substitution character while loading file XXX.cs with Chinese Simplified (GB2312) encoding

    When we use <strong>visual studio</strong> open source file or any other file, we may en ...

  9. SQL练习之两个列值的交换

    SELECT * FROM dbo.test2

  10. JavaSE思维导图(二)