UVA 10791 -唯一分解定理的应用
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;
int main(){
int n;
int k=;
while(){
k++;
scanf("%d",&n);
if (n==)break;
int m=sqrt(n+);
int cnt=;
ll ans=;
for (int i=;i<=m;i++){
if (n%i==){
ll num=;
cnt++;
while(n%i==){
num*=i;
n/=i;
}
ans+=num;
}
if (n==)break;
}
if (n!= || cnt==){
ans+=n;
cnt++;
}
if (cnt==){
ans++;
}
printf("Case %d: %lld\n",k,ans); }
return ;
}
UVA 10791 -唯一分解定理的应用的更多相关文章
- UVa 1635 (唯一分解定理) Irrelevant Elements
经过紫书的分析,已经将问题转化为求组合数C(n-1, 0)~C(n-1, n-1)中能够被m整除的个数,并输出编号(这n个数的编号从1开始) 首先将m分解质因数,然后记录下每个质因子对应的指数. 由组 ...
- UVa 10375 (唯一分解定理) Choose and divide
题意: 求组合数C(p, q) / C(r, s)结果保留5为小数. 分析: 先用筛法求出10000以内的质数,然后计算每个素数对应的指数,最后再根据指数计算答案. #include <cstd ...
- UVA - 11388 唯一分解定理
题意:给出G和L,求最小的a使得gcd(a,b)=G,lcm(a,b)=L 显然a>=G,所以a取G,b要满足质因子质数为L的同次数,b取L //此处应有代码
- UVA - 10780 唯一分解定理
白书P171 对m,n!分解,质因子指数取min #include<iostream> #include<algorithm> #include<cstdio> # ...
- UVA.10791 Minimum Sum LCM (唯一分解定理)
UVA.10791 Minimum Sum LCM (唯一分解定理) 题意分析 也是利用唯一分解定理,但是要注意,分解的时候要循环(sqrt(num+1))次,并要对最后的num结果进行判断. 代码总 ...
- UVa 10791 Minimum Sum LCM【唯一分解定理】
题意:给出n,求至少两个正整数,使得它们的最小公倍数为n,且这些整数的和最小 看的紫书--- 用唯一分解定理,n=(a1)^p1*(a2)^p2---*(ak)^pk,当每一个(ak)^pk作为一个单 ...
- 唯一分解定理(以Minimun Sum LCM UVa 10791为例)
唯一分解定理是指任何正整数都可以分解为一些素数的幂之积,即任意正整数n=a1^p1*a2^p2*...*ai^pi:其中ai为任意素数,pi为任意整数. 题意是输入整数n,求至少2个整数,使得它们的最 ...
- Uva 10791 最小公倍数的最小和 唯一分解定理
题目链接:https://vjudge.net/contest/156903#problem/C 题意:给一个数 n ,求至少 2个正整数,使得他们的最小公倍数为 n ,而且这些数之和最小. 分析: ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
随机推荐
- dialog 关闭 清除
div.dialog({ close: function () { $(this).dialog('destroy').remove(); } });
- Windows Server 2016-Active Directory复制概念(二)
本章继续补充有关Active Directory复制概念,具体内容如下: 连接对象: 连接对象是一个Active Directory对象,表示从源域控制器到目标域控制器的复制连接.域控制器是单个站点的 ...
- Windows 命令行
1.d: 进入d盘 2.dir(directory) 显示当前文件夹下的所有内容 3.md (make directory) +文件夹名 在当前文件夹下创建文件夹 4.rd (remove ...
- March 07th, 2018 Week 10th Wednesday
Better later than never. 亡羊补牢,时犹未晚. Time and again all of us are told to complete the tasks assigned ...
- March 02nd, 2018 Week 9th Friday
Make hay while the sun shines. 勿失良机. Last night the toothache woke me up and it was very difficult f ...
- SpringCloud之初识Zuul(网关)---动态路由,权限验证
通过前面的学习,使用Spring Cloud实现微服务的架构基本成型,大致是这样的: 我们使用Spring Cloud Netflix中的Eureka实现了服务注册中心以及服务注册与发现:而服务间通过 ...
- 《Linux服务器的监控》
本文地址:http://www.cnblogs.com/aiweixiao/p/7131532.html 原文地址(公众号):http://t.cn/RKwmqUs 点击关注 微信公众号 1. 监控概 ...
- 高可用,完全分布式Hadoop集群HDFS和MapReduce安装配置指南
原文:http://my.oschina.net/wstone/blog/365010#OSC_h3_13 (WJW)高可用,完全分布式Hadoop集群HDFS和MapReduce安装配置指南 [X] ...
- Eclipse debug 断点不能调试 ,Eclipse Unable to install breakpoint in 解决办法
解决:[1]项目工程名 ,右键 --> properties --> java compiler -->class file Generation 位置 Add line numb ...
- Leetcode:0027
Leetcode:0027 题目:给定一个数组 nums 和一个值 val,你需要原地移除所有数值等于 val 的元素,返回移除后数组的新长度.不要使用额外的数组空间,你必须在原地修改输入数组并在使用 ...