Project Euler:99 Largest exponential C++
Comparing two numbers written in index form like 211 and 37 is not difficult, as any calculator would confirm that 211 = 2048 < 37 = 2187.
However, confirming that 632382518061 > 519432525806 would be much more difficult, as both numbers contain over three million digits.
Using base_exp.txt (right click and 'Save Link/Target As...'), a 22K text file containing one thousand lines with a base/exponent pair on each line, determine which line number has the greatest numerical value.
NOTE: The first two lines in the file represent the numbers in the example given above.
用对数做,转化成 n=y*ln x,n为10的指数。也就是比较以10 为底,对数值的大小。
C++中,ln写作log。
实现部分如下:
int n=log(x)*y;
if(max<n){
max=n;
ans=num;
} // ans= 709;
Project Euler:99 Largest exponential C++的更多相关文章
- Project Euler 99:Largest exponential 最大的幂
Largest exponential Comparing two numbers written in index form like 211 and 37 is not difficult, as ...
- 【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 × ...
- Project Euler:Problem 86 Cuboid route
A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the o ...
- Project Euler:Problem 63 Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is ...
- Project Euler:Problem 76 Counting summations
It is possible to write five as a sum in exactly six different ways: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 ...
- Project Euler:Problem 87 Prime power triples
The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is ...
- Project Euler:Problem 41 Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- Project Euler:Problem 61 Cyclical figurate numbers
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygon ...
- Project Euler:Problem 33 Digit cancelling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
随机推荐
- 在word表格里打勾和打叉
打勾:在单元格里输入R,再将其字体设置为:Wingdings 2. 打叉:在单元格里输入T,再将其字体设置为:Wingdings 2.
- js添加删除元素内容
<body> <div id="div" style="background: yellow;width:200px;height:200px;&quo ...
- Azkaban3.x集群部署(multiple executor mode)
介绍 Azkaban是由Linkedin公司推出的一个批量工作流任务调度器,用于在一个工作流内以一个特定的顺序运行一组工作和流程.Azkaban使用job配置文件建立任务之间的依赖关系,并提供一个易于 ...
- Windows8.1 与Ubuntu14.04双系统
机型:联想 Y480 现有操作系统:win8.1 64位 物理内存:8G 磁盘存储:两个硬盘 1. SSD为固态盘 Solid State Drives 110G 现已安装有win8系统 2.H ...
- Ubuntu 发行版的 Linux 操作系统
Ubuntu 发行版的 Linux 操作系统.. ------------------------------------- ------------------------------------- ...
- DRAM(MT48LC8M32B2)学习
Micron公司,型号为MT48LC8M32B2的DRAM,其86PIN的 TSOP封装引脚定义 Micron公司,型号为MT48LC8M32B2的DRAM,其86PIN的 TSOP封装引脚定义如上图 ...
- MyEclipse 2014各种优化设置
各种优化大整合,陆续更新使用中的问题,也欢迎大家提问. 1.通用优化设置:字体,UTF-8编码格式设置: http://jingyan.baidu.com/article/b907e627d2c5da ...
- oracle之备份详解
1.冷备份(执行冷备份前必须关闭数据库) 物理备份(备份物理数据库文件) 2.热备份(热备份是当数据库正在运行时进行数据备份的过程.执行热备份的前提是:数据库运行在可归档日志模式.适用于24X7不间断 ...
- texlive、
0.1 卸载 texlive2007 如果系统没有安装过texlive,则跳过第0步. 可以在终端中使用如下命令查询本机已经安装的tex和latex版本: [She@She LaTex_test]$ ...
- 再起航,我的学习笔记之JavaScript设计模式18(观察者模式)
观察者模式 观察者模式(Observer): 又被称为发布-订阅者模式或消息机制,定义了一种依赖关系,解决了主体对象与观察者之间功能的耦合. 创建一个观察者对象 首先我们创建一个闭包对象,让其在页面加 ...