题意:给出一个x 可以做两种操作  ①sqrt(x)  注意必须是完全平方数  ② x*=k  (k为任意数)  问能达到的最小的x是多少

思路: 由题意以及 操作  应该联想到唯一分解定理   经过分析可以知道   ②操作最多使用一次  将x分解成一系列素数乘积的时候  只要看最高幂次离哪个二的幂近(只取上界)

并且把所以素因子都凑成找到的这个二的幂  只要x*=k一步就可以凑成  然后一直操作①模拟即可 而如果刚好全部都相等并且都是2的幂次 那么直接一直操作①模拟即可

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+;
int fac[maxn],mi[maxn];
int solve(int x){
ll tmp=;
for(int i=;;i++){
if(tmp>=x){
return i;
}
else tmp<<=;
}
}
map<ll,int>mp;
int main(){
int n;
scanf("%d",&n);
ll la=;
for(int i=;i<=;i++){
la<<=;
if(la>)break;
mp[la]=;
}
if(n==){
cout<<<<" "<<<<endl;
return ;
}
int flag=;
long long ans=;
for(int i=;i<=n;i++){
if(n%i==){
fac[flag]=i;
ans*=i;
while(n%i==){
n/=i;
mi[flag]++;
}
flag++;
}
}
int maxnum=;
int cnt=;
int ok=;
for(int i=;i<flag;i++){
maxnum=max(maxnum,mi[i]);
if(mp[mi[i]]!=)ok=;
if(i>&&mi[i]!=mi[i-])ok=;
}
if(maxnum==){
cout<<ans<<" " <<<<endl;
return ;
}
if(maxnum&)maxnum++;
if(ok)cnt++;
// cout<<maxnum<<endl;
cnt+=solve(maxnum);
cout<<ans<<" "<<cnt<<endl;
return ;
}

Codeforces Round #520 (Div. 2) B. Math 唯一分解定理+贪心的更多相关文章

  1. Codeforces Round #520 (Div. 2) B. Math

    B. Math time limit per test:1 second memory limit per test:256 megabytes Description: JATC's math te ...

  2. Codeforces Round #520 (Div. 2) B math(素数因子的应用)

    题意: 给出一个n ; 有两个操作: 1,mul A   ,   n=n*A   : 2,sqrt()  ,  n=sqrt(n)  开更出来必须是整数 : 求出经过这些操作后得出的最小  n , 和 ...

  3. Codeforces Round #520 (Div. 2)

    Codeforces Round #520 (Div. 2) https://codeforces.com/contest/1062 A #include<bits/stdc++.h> u ...

  4. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  5. CF每日一练 Codeforces Round #520 (Div. 2)

    比赛过程总结:过程中有事就玩手机了,后面打的状态不是很好,A题理解错题意,表明了内心不在状态,B题想法和思路都是完全正确的,但是并没有写出来,因为自己代码能力不强,思路不是特别清晰,把代码后面写乱了, ...

  6. Codeforces Round #520 (Div. 2) E. Company(dfs序判断v是否在u的子树里+lca+线段树)

    https://codeforces.com/contest/1062/problem/E 题意 给一颗树n,然后q个询问,询问编号l~r的点,假设可以删除一个点,使得他们的最近公共祖先深度最大.每次 ...

  7. Codeforces Round #520 (Div. 2) Solution

    A. A Prank Solved. 题意: 给出一串数字,每个数字的范围是$[1, 1000]$,并且这个序列是递增的,求最多擦除掉多少个数字,使得别人一看就知道缺的数字是什么. 思路: 显然,如果 ...

  8. Codeforces Round #520 (Div. 2) D. Fun with Integers

    D. Fun with Integers 题目链接:https://codeforc.es/contest/1062/problem/D 题意: 给定一个n,对于任意2<=|a|,|b|< ...

  9. Codeforces Round #520 (Div. 2) C. Banh-mi

    C. Banh-mi time limit per test:1 second memory limit per test:256 megabytes 题目链接:https://codeforc.es ...

随机推荐

  1. 为什么使用 Redis 及其产品定位

    一:传统 MySQL+ Memcached 架构遇到的问题 实际 MySQL 是适合进行海量数据存储的,通过 Memcached 将热点数据加载到 cache,加速访问,很多公司都曾经使用过这样的架构 ...

  2. [转]How to Download and Setup Blue Prism

    本文转自:https://www.hopetutors.com/blog/uncategorized/how-to-download-and-setup-blue-prism/ The Downloa ...

  3. spring aop中pointcut表达式完整版

    spring aop中pointcut表达式完整版 本文主要介绍spring aop中9种切入点表达式的写法 execute within this target args @target @with ...

  4. Dubbo和Spring Cloud微服务架构'

    微服务架构是互联网很热门的话题,是互联网技术发展的必然结果.它提倡将单一应用程序划分成一组小的服务,服务之间互相协调.互相配合,为用户提供最终价值.虽然微服务架构没有公认的技术标准和规范或者草案,但业 ...

  5. Android View的重绘过程之Measure

    博客首页:http://www.cnblogs.com/kezhuang/p/ View绘制的三部曲,  测量,布局,绘画今天我们分析测量过程 view的测量是从ViewRootImpl发起的,Vie ...

  6. 问题解决--无法解析的外部符号 _imp_XXXXXXXXX

    错误示例: 出现字符_imp,说明不是真正的静态库,而是某个动态库的导入库,导入函数和自己不同名,所以加了字符_imp.比如说_imp_GetUserNameA就是GetUserNameA函数. 会报 ...

  7. 使用Log4Net进行错误日志记录

    http://blog.csdn.net/zdw_wym/article/details/48802821

  8. windows 2008 开机启动 Docker Toolbox 并运行容器

    新建 docker-startup.bat @echo off REM Set the name of the VM configuration where dockerd will be hoste ...

  9. css之overflow应用

    overflow应用的两个小例子: 1.单行文本出现省略号的情况 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...

  10. margin塌陷与margin合并(margin),清除浮动

    **1.margin塌陷**问题:垂直方向的父子关系的盒子使用不当会产生margin塌陷.给子级设置margin-top时,他不会相对父级一起动,只有他的margin超过父级的margin时,才会生效 ...