UVA 10892 - LCM Cardinality(数学题)
写写,就ok了。
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
#define MOD 1000000
#define LL long long
int prim[];
int o[];
int main()
{
int i,j,num = ,temp;
LL n;
for(i = ;i <= ;i ++)
{
if(!o[i])
{
for(j = i+i;j <= ;j += i)
o[j] = ;
}
}
for(i = ;i <= ;i ++)
{
if(!o[i])
prim[num++] = i;
}
while(cin>>n)
{
if(!n) break;
cout<<n<<" ";
LL ans = ;
for(i = ;i < num;i ++)
{
temp = ;
while(n%prim[i] == )
{
temp ++;
n /= prim[i];
}
ans *= ((temp+)*-);
}
if(n != )
ans *= ;
cout<<ans/ +<<endl;
}
return ;
}
UVA 10892 - LCM Cardinality(数学题)的更多相关文章
- UVA 10892 - LCM Cardinality
Problem F LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair ...
- 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 ...
- UVA 10892 LCM Cardinality(数论 质因数分解)
LCM Cardinality Input: Standard Input Output: Standard Output Time Limit: 2 Seconds A pair of number ...
- Uva 10892 LCM Cardinality (数论/暴力)
题意:给出数n,求有多少组A,B的最小公约数为n; 思路:3000ms,直接暴力寻找,找到所有能把n整除的数 pi, 枚举所有pi 代码: #include <iostream> #inc ...
- LCM Cardinality 暴力
LCM Cardinality Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit St ...
- UVa 10892 (GCD) LCM Cardinality
我一直相信这道题有十分巧妙的解法的,去搜了好多题解发现有的太过玄妙不能领会. 最简单的就是枚举n的所有约数,然后二重循环找lcm(a, b) = n的个数 #include <cstdio> ...
- LCM Cardinality UVA - 10892(算术基本定理)
这题就是 LightOJ - 1236 解析去看这个把https://www.cnblogs.com/WTSRUVF/p/9185140.html 贴代码了: #include <iostrea ...
- uva 10892
试了一下纯暴力 结果过了 无话可说 应该有更好的方法...... /**************************************************************** ...
- LCM Cardinality
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31675#problem/E 暴力 // File Name: uva10892.cpp ...
随机推荐
- Nginx详解(一)
1.Nginx是什么? Nginx就是反向代理服务器. 首先我们先来看看什么是代理服务器,代理服务器一般是指局域网内部的机器通过代理服务发送请求到互联网上的服务器,代理服务器一般作用于客户端.比如Go ...
- 关于Mesos和Kubernetes的区别
这个主题应该和服务发现注册一样,进入视野...
- 协处理器,王明学learn
协处理器 协处理器用于执行特定的处理任务,如:数学协处理器可以控制数字处理,以减轻处理器的负担.ARM可支持多达16个协处理器,其中CP15是最重要的一个. CP15提供16组寄存器 通过提供的16组 ...
- MathType 常用快捷键
MathType 数学公式编辑器是广大理科生电脑上必不可少的软件!然而在大量公式时,不会巧妙使用快捷键真的是心累身累.巧妙使用MathType数学公式编辑器可加快数学符号的录入速度和效率,这将节约大量 ...
- jQuery Mobile Datepicker 使用
插件引入文件: <meta name="viewport" content="width=device-width, initial-scale=1"&g ...
- ios程序播放音频文件
1.控制器代码 #import "ViewController.h" #import <AVFoundation/AVFoundation.h> #import &qu ...
- MyBatis入门案例 增删改查
一.MyBatis入门案例: ①:引入jar包 ②:创建实体类 Dept,并进行封装 ③ 在Src下创建大配置mybatis-config.xml <?xml version="1.0 ...
- .NET C# Tostring() format 格式化字符串大全
C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...
- Android 在地图上画矩形
point1=map.toMapPoint(400,426); point2=map.toMapPoint(600,640); initextext = new Envelope(point1.get ...
- 去掉开始菜单中新装程序的红色标记【Windows】
右键开始,属性,开始菜单,自定义,去掉突出新程序.完成.