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. [LeetCode]题解(python):155-Min Stack

    题目来源: https://leetcode.com/problems/min-stack/ 题意分析: 实现一个小的栈,包括初始化,push,pop,top,和getMin. 题目思路: 私用是用两 ...

  2. python特性、属性以及私有化

    python中特性attribute 特性是对象内部的变量 对象的状态由它的特性来描述,对象的方法可以改变它的特性 可以直接从对象外部访问特性 特性示例: class Person: name = ' ...

  3. visual studio 配置OpenGL环境

    首先在网上下载一个GLUT工具包. glut.zip,大约一百多kb. 解压之后得到这么几个文件: 将glut.h复制到C:\Program Files (x86)\Microsoft Visual ...

  4. java 执行linux命令

    原文地址: http://blog.csdn.net/xh16319/article/details/17302947 package scut.cs.cwh; import java.io.Inpu ...

  5. 基于Web的系统测试方法

    基于Web的系统测试与传统的软件测试既有相同之处,也有不同的地方,对软件测试提出了新的挑战.基于Web的系统测试不但需要检查和验证是否按照设计的要求运行,而且还要评价系统在不同用户的浏览器端的显示是否 ...

  6. 《转》精巧好用的DelayQueue

    该文章转自:http://www.cnblogs.com/jobs/archive/2007/04/27/730255.html 我们谈一下实际的场景吧.我们在开发中,有如下场景 a) 关闭空闲连接. ...

  7. SQL Server 使用ROW_NUMBER()进行分页

    代码示例: WITH domain AS(SELECT ROW_NUMBER() OVER(ORDER BY ID DESC) ids,* FROM dbo.DomainInfo) SELECT * ...

  8. SQL知识三(Day 27)

    大家好,好几天都没写博客了.因为自己的一些原因,落下了很多.今天没有学什么新的知识,自己就把以前落下的好好看了一下.好了,今天就先总结一下SQL剩下的一些知识吧. 主要学的知识有:循环语句(case语 ...

  9. 第一个输出程序 Console.WriteLine

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. C++_知识点_namespace

    #include <iostream> #include <string> using namespace std; void name() { cout << & ...