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 ...
随机推荐
- 【物联网云端对接-4】通过MQTT协议与百度云进行云端通信
百度云的天工物联网服务目前包括:物接入.物解析.物管理.时序数据库和规则引擎等5大部分,本篇文章仅介绍物接入. 天工物联网的物接入,从开发者的角度来说相对有些复杂,需要多步操作才能实现一个云设备的创建 ...
- java调用copy复制子文件夹及文件到指定目录(非xcopy)
因为作所以烦因为烦所以快乐...(为什么不先查一下有没有现成的命令,后悔啊!!) 不知道有xcopy这个命令就自己想写个复制子目录和文件的功能...以下故事诞生了 是这样的,昨天在学校弄的半成品,半成 ...
- 【Ubuntu 16】安装net-snmp
使用tar.gz压缩包安装mongodb时报错,没有库文件 libnetsnmpmibs.so.3o cannot open file or directory 在网上找了一篇文章 需要安装net-s ...
- windows转储文件(dmp)
1. 何为转储文件 转储文件也就是我们常说的dump文件.可以把转储文件看成软件的某个时刻的一个快照.转储文件一般都是在软件出现问题时手动生成或者程序自动生成.下面我们介绍几种生成转储文件的 ...
- 分页 js
纯js分页代码 ' .news-pages { } .news-page { } .page-first,.page-last { } .page-next { } .page-one { } { } ...
- Mysql数据库索引
今天,我们来讲讲Mysql数据库的索引的一些东西,想必大家都知道索引能干吗?必然是查找数据表的时候,查找的速度快啊,尤其是那些几百万行的数据库,不建立索引,你是想考验用户的耐心吗?Mysql有多种存储 ...
- Django连接mysql数据库
1.app中对应的models.py配置相关表结构信息 from django.db import models class Question(models.Model): question_text ...
- 函数作用域中的this问题
首先一起回顾下预解析和作用域吧: 预解析: 浏览器每读到一个script标签或function,先不执行任何代码,会先把整个代码快速的浏览一遍,然后从中 挑出 var 和 function两个关键字 ...
- Myeclipse去掉恶心的弹框
错误提示: 解决方法: 把JavaScript Validator去掉.去掉的方法是:选择一个项目—-右键Properties—-Builders(排第二)—-点一下右侧会有四项—-取消第一项“Jav ...
- git 工作流介绍
GIT Git工作流你可以理解为工作中团队成员遵守的一种代码管理方案,在Git中有以下几种工作流方案作为方案指导: 集中式工作流 功能开发工作流 Gitflow工作流 Forking工作流 下面针对性 ...