看了大佬的博客才会写的 传送门

#include<bits/stdc++.h>
using namespace std;#define int long longint lowbit(int x)
{return x&(-x);
}int ans=0;int getl(int x)
{int n=0;for(;x;x-=lowbit(x))n++;return n;
}void dfs(int x,int sum,int k,int s)
{if(sum>s){ans=min(ans,k+getl(s));return;}dfs(x+1,sum*x,k+1,s-sum);dfs(x+1,sum*x,k,s);
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t,m;cin>>t;while(t--){cin>>m;ans=getl(m);dfs(4,6,0,m);cout<<ans<<endl;}
}

CodeForces - 1646C Factorials and Powers of Two相关推荐

  1. Codeforces 1646C Factorials and Powers of Two

    0x10 题目链接 cf 1646c 0x20 题目 0x21 Tag 状态压缩,枚举 0x22 题目描述 0x23 翻译 给出一个数n,是否能将其拆解成多个**(共k个)**2的幂次与阶乘的和,求k ...

  2. CF 1646C Factorials and Powers of Two

    题目 思路 只有2的指数阶和n的阶层所构成 数据范围是101210^{12}1012,恰好在2402^{40}240和15!15!15!以内 总所周知,每一个整数都可以转换为相应的二进制数, 对应这道 ...

  3. CodeForces 305C Ivan and Powers of Two【set】

    这个题啊,纠结了本公举一中午,知道如果出现了重复的,就要往后移,差点就把自己想的恶心的bool 数组付诸实现了,== 既然是思维的题,借助了STL的特性是再正常不过的了,既然想写数组,先应该想想Set ...

  4. Codeforces Round #774 (Div. 2) A-D

    A. Square Counting 思路 签到 #include <bits/stdc++.h> using namespace std; int main() {ios::sync_w ...

  5. CodeForce 774 div2 A-C,E题解

    E. Power Board 思路 重复的数是从哪里来的?比如4 = 2 2 2^2 22, 那么 4 2 4^2 42 就会跟 ( 2 2 ) 2 (2^2)^2 (22)2 = 2 4 2^4 2 ...

  6. Codeforces 955C Sad powers(数论)

    Codeforces 955C Sad powers 题意 q组询问,每次询问给定L,R,求[L,R]区间内有多少个数可以写成ap的形式,其中a>0,p>1,1 ≤ L ≤ R ≤ 1e1 ...

  7. Relatively Prime Powers CodeForces - 1036F (莫比乌斯函数容斥)

    Relatively Prime Powers CodeForces - 1036F Consider some positive integer xx. Its prime factorizatio ...

  8. Educational Codeforces Round 50: F. Relatively Prime Powers(莫比乌斯函数)

    F. Relatively Prime Powers 题意: 给你一个n,问满足在[2,n]范围内有多少个数是非次方数(也就是不是这样的) 思路: 答案就是 原理是利用容斥,注意n开i次根是向下取整( ...

  9. Codeforces 955C Sad powers

    C. Sad powers time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

最新文章

  1. python3-Python3.7.0官方版
  2. 机器人学习--定位、建图和导航问题从古至今
  3. JVM的内存区域划分(转)
  4. 排序算法以及基本数据结构
  5. Uva 437 - The Tower of Babylon(DP)
  6. MinGW找不到Gcc的解决方法
  7. 软件工程实践专题第三次团队作业
  8. 大数据是如何作用于实体经济
  9. 使用JSON作为函数的参数(转载)
  10. 如何验证远程服务器上文件是否存在
  11. php redis 定时任务,利用redis实现定时任务,完全不需要crontab
  12. kali中安装使用msfconsole
  13. kmeans设置中心_kmeans算法
  14. 关于快速幂与快速积取模实现的尝试
  15. 国内使用bing国际版(非国内国际切换版本)
  16. 37 | 个人成长:学习安全,哪些资源我必须要知道?
  17. 总结一下面试中经常被问到的面试题,希望对各位初中级同胞有用。
  18. 【实习日志】The last Day总结篇
  19. C语言笔记:进制转换与32位二进制IP地址转换十进制问题
  20. TVS (瞬态二极管)

热门文章

  1. 浅谈互联网行业发展趋势及现状
  2. 基于服务器搭建部署的疫情动态地图
  3. GPU的发展史,GPU与CPU的关系是什么?为何现在GPU越来越重要?
  4. 5分钟了解《代码整洁之道》精华
  5. vue父子组件生命周期执行顺序
  6. 华为云GaussDB(for Redis)GaussDB(for Redis)全面对比Codis
  7. 微信小程序导航头部吸顶效果
  8. excle报盘之导入报盘
  9. 礼盒抖动动画(CocosCreator)
  10. python report_ReportPortal(自动化报表统一平台)的搭建与python推送