结论貌似是,,,肯定只有没有重复的数字。http://hzwer.com/6426.html

一开始猜的是贪心,感觉也是可以的啊。。。(想想都有道理,然而看到是神奇的(dp类)记忆化搜索,直接虚的不敢写。。)

 #include <bits/stdc++.h>
#define LL long long
#define lowbit(x) x&(-x)
#define inf 2e18
using namespace std;
inline LL ra()
{
LL x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
LL f[],n;
int top,P;
map<LL, int > F;
int solve(LL x)
{
if (F[x]) return F[x];
int t=lower_bound(f,f+top,x)-f;
if (f[t]==x) return ;
return F[x]=min(solve(x-f[t-]),solve(f[t]-x))+;
}
int main()
{
f[]=; f[]=;
for (int i=; f[i-]<=inf; i++,top++) f[i]=f[i-]+f[i-];
P=ra();
for (int i=; i<=P; i++)
printf("%d\n",solve(ra()));
return ;
}

最新文章

  1. [Penetration Testing Devil Training Camp Based on Metasploit] Learn &amp; Practice
  2. linux 多线程基础
  3. Jenkins console输出乱码???
  4. 前端工程师IE6兼容性问题随笔(未完待续)
  5. JavaScript的Ajax请求示例
  6. 10、技术经理要阅读的书籍 - IT软件人员书籍系列文章
  7. Jstat在分析java的内存GC时的应用
  8. mysql 前缀索引
  9. C语言 电梯函数
  10. CSS3新的字体尺寸单位rem
  11. tomcat上servlet程序的配置与处理servlet请求过程
  12. JDK中日期和时间的几个常用类浅析(三)
  13. 访问Access日期字段
  14. vue 2.0 scopedSlots和slots在render函数中的应用示例
  15. python itertools 模块
  16. Python之旅Day7 面向对象&amp;异常处理
  17. Python Tkinter 简单使用
  18. elk-nginx输出json格式的日志
  19. jmeter函数简介
  20. 树莓派 SD卡镜像备份

热门文章

  1. YUV颜色编码格式
  2. HTML中元素 标签 属性
  3. 【快学springboot】9.使用 @Transactional 注解配置事务管理
  4. 吴裕雄--天生自然HADOOP操作实验学习笔记:Wor的Count程序的编写
  5. Ubuntu安装docker并修改镜像仓库
  6. 通过JAVA反射修改JDK1.6*当中DNS缓存内容
  7. jmeter之Xpath提取器
  8. OS、浏览器排名:Win10狂飙、Chrome逆天
  9. UVA10820 交表 Send a Table
  10. Spring组件扫描--源码跟踪