project euler 169

题目链接:https://projecteuler.net/problem=169

参考题解:http://tieba.baidu.com/p/2738022069

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(x) (int)x.size()
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
typedef __int128 ll;
typedef pair<int, int> pii;
typedef vector<int> vi; map<ll, ll> vis; ll solve(ll n) {
if(n<0) return 0;
if(n==0) return 1;
if(vis.count(n)) return vis[n];
if(n&1) return vis[n]=solve(n/2);
return vis[n]=solve(n/2)+solve(n/2-1);
} void print(ll x) {
vi ans;
while(x) {
ans.pb(x%10);
x/=10;
}
reverse(ans.begin(), ans.end());
rep(i,0,sz(ans)) printf("%d",ans[i]);puts("");
} int main() {
ll x=1e12;
ll n=x*x*10;
print(n);
ll ans=solve(n);
print(ans);
return 0;
}

project euler 169的更多相关文章

  1. [project euler] program 4

    上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出 ...

  2. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  3. Project Euler 9

    题意:三个正整数a + b + c = 1000,a*a + b*b = c*c.求a*b*c. 解法:可以暴力枚举,但是也有数学方法. 首先,a,b,c中肯定有至少一个为偶数,否则和不可能为以上两个 ...

  4. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  5. 【Project Euler 8】Largest product in a series

    题目要求是: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × ...

  6. Project Euler 第一题效率分析

    Project Euler: 欧拉计划是一系列挑战数学或者计算机编程问题,解决这些问题需要的不仅仅是数学功底. 启动这一项目的目的在于,为乐于探索的人提供一个钻研其他领域并且学习新知识的平台,将这一平 ...

  7. Python练习题 049:Project Euler 022:姓名分值

    本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names sco ...

  8. Python练习题 048:Project Euler 021:10000以内所有亲和数之和

    本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...

  9. Python练习题 047:Project Euler 020:阶乘结果各数字之和

    本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...

随机推荐

  1. Android studio--几个生成文件的区别:Make Project、Make Module、Build apk、Signed apk

    参考资料: https://stackoverflow.com/questions/35334319/difference-between-make-project-make-module-app-b ...

  2. Web前端学习资料

    http://www.imooc.com/course/list?c=html http://www.w3cplus.com/ http://www.w3cfuns.com/ http://www.w ...

  3. Gauva的安装——入门篇

    Guava工程包含了若干被Google的 Java项目广泛依赖 的核心库,例如:集合 [collections] .缓存 [caching] .原生类型支持 [primitives support] ...

  4. 微信小程序button选中改样式-实现单选/多选

    小程序实现多button单选/多选 红色为选中状态 单选 多选 ①wxss /* pages/button-select/button-select.wxss */ .button_container ...

  5. 微信小程序二维码识别

    目前市场上二维码识别的软件或者网站越来越多,可是真正方便,无广告的却少之很少. 于是,自己突发奇想做了一个微信二维码识别的小程序. 包含功能: 1.识别二维码 ①普通二维码 ②条形码 ③只是复制解析出 ...

  6. MySQL 索引知识总结

    将 mysql 的索引以书本的索引类比比较贴切,要找到一个关键字为xxx 的条目,首先翻到索引中查找有哪些页码涉及到,无疑就缩小了范围.在这个小范围内再寻找符合条件的数据,效率就会提高许多. mysq ...

  7. dubbo客户端源码分析(一)

    rpc框架有很多,公司自研.开源的thrift.dubbo.grpc等.我用过几个框架,了解了一下实现原理,客户端基本都是用代理实现,jdk动态代理.cglib等.最近一段时间想了解一下dubbo源码 ...

  8. 最大行走路线问题(DP)

    在一个NxN的棋盘上,每个格子里有若干个棋子,假设起点为左上角的格子,且每次只能向下或向右走一格,问怎样走才能得到最多的棋子. 这是很简单的递推题了. 因为只能向下或者向右,所以其实我们可以把棋盘看成 ...

  9. System Test GIS压力测试利器

    System Test是ESRI公司提供一个压力测试软件.能针对ArcGIS Server 地图服务.WMS服务.WFS服务.WCS服务接口进行压力测试.以下是一个针对ArcGIS Server 地图 ...

  10. osgEarth编译——以VS2012为例

    整理记录下 osgEarth编译过程. osgEarth是依赖于OSG的三维地理平台. 准备工作 OpenSceneGraph-3.4.0.zip OSG_3RDPARTY_DIR    http:/ ...