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 ...
随机推荐
- 在Win7 64位注册ActiveX控件
首先必须以管理员身份运行cmd.exe,即在cmd.exe右键选择以管理员身份运行. 目前共有两个存在网络盘的文件需要注册,一个dll,一个ocx. 开始时将两个文件都拷贝到c:\wind ...
- 【转载】Python编写简易木马程序
转载来自: http://drops.wooyun.org/papers/4751?utm_source=tuicool 使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马. 首先准备好 ...
- Java程序员要求具备的10项技能
1.语法:必须比较熟悉,在写代码的时候IDE的编辑器对某一行报错应该能够根据报错信息知道是什么样的语法错误并且知道任何修正. 2.命令:必须熟悉JDK带的一些常用命令及其常用选项,命令至少需要熟悉:a ...
- [LeetCode] Gas Station
Recording my thought on the go might be fun when I check back later, so this kinda blog has no inten ...
- Git学习笔记 git revert
我们难免会因为种种原因执行一些错误的commit / push,git提供了revert命令帮助程序员修复这样的错误. 举个例子,下图是git commit 的历史记录 git revert 命令会通 ...
- Oracle备份 还原命令
1.备份命令 exp username/password file=d:/test/test.dmp; 2.还原命令 imp username/password full=y file=d:/test ...
- VS2012 配置 OpenCV3.0
VS2012 配置 opencv3.0,相比之前的版本,3.0的配置简单了好多. 通过配置属性文件,可以做到一次配置,重复使用! 根据文章的操作在 win7 64bit VS2012 下成功配置 op ...
- Request和Response对象
Request 和 Response 对象起到了服务器与客户机之间的信息传递作用.Request 对象用于接收客户端浏览器提交的数据,而 Response 对象的功能则是将服务器端的数据发送到客户端浏 ...
- [荐]Js apply()和call()方法详解 - http://www.w3cfuns.com/article-5596443-1-1.html
本帖最后由 默默DE人生 于 2013-3-19 13:22 编辑 Js apply方法详解我在一开始看到javascript的函数apply和call时,非常的模糊,看也看不懂,最近在网上看到一些文 ...
- 在苹果手机上input有内阴影怎么去除
一个input中在安卓手机上完全按照自己的样式去展示,但是在苹果手机上发现Input有内阴影,怎么去除内阴影呢? 在input样式中这样添加 #div{ .... appearance:button; ...