The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.

How many n-digit positive integers exist which are also an nth power?

这种数字满足下面条件:

对于数位为x的数S=k^x 有 10^(x-1)<=k^x<=10^x-1

#include "stdafx.h"
#include <iostream>
using namespace std; int main()
{
int count = 0;
for (int i = 1; i < 100; i++)
{
double n = pow(10, 1.0 - 1.0 / i);
int tmp = int(n);
if (n - tmp>0.0)
tmp++;
if (tmp > 9)
break; count += 9 - tmp + 1;
//cout << n << " " << tmp << endl;
}
cout << count << endl;
system("pause");
return 0;
}

Project Euler:Problem 63 Powerful digit counts的更多相关文章

  1. Project Euler 63: Powerful digit counts

    五位数\(16807=7^5\)也是一个五次幂,同样的,九位数\(134217728=8^9\)也是一个九次幂.求有多少个\(n\)位正整数同时也是\(n\)次幂? 分析:设题目要求的幂的底为\(n\ ...

  2. Project Euler:Problem 34 Digit factorials

    145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...

  3. Project Euler:Problem 33 Digit cancelling fractions

    The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...

  4. Project Euler:Problem 55 Lychrel numbers

    If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindr ...

  5. Project Euler:Problem 32 Pandigital products

    We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. Project Euler:Problem 89 Roman numerals

    For a number written in Roman numerals to be considered valid there are basic rules which must be fo ...

随机推荐

  1. win7 64位系统及开发环境重装后的总结

    前言 话说来这家公司之后就一直使用这个系统,现在感觉这系统跑的实在是有点慢了,运行,调试各种浪费时间呀,不过也用了将近20个月了,这也可以说是我用的最久的一个系统了.由于新项目即将拉开战幕,所以自己趁 ...

  2. SqlServer 还原数据库 代码实现

    RESTORE DATABASE TargetDB FROM DISK = 'D:\DataBase\DB.bak' with replace, MOVE 'DB' TO 'D:\DataBase\T ...

  3. 最常使用Eclipse快捷键

    一:编辑 alt+/:智能感知: alt+shift+s:出现代码块: ctrl+1:quick fix,同时还有简单的重构功能: ctrl+e:快速转换编辑器 ,这组快捷键将帮助你在打开的编辑器之间 ...

  4. Django model 中设置联合约束和联合索引

    来自:https://blog.csdn.net/ding_312/article/details/81264910 class Cart(models.Model): user = models.F ...

  5. 如何确定一个NFS的mount是v3还是v4?

    命令如下: nfsstat –m nfsstat –m | grep /home/mymnt 参考资料 ============ https://unix.stackexchange.com/ques ...

  6. JQuery之ContextMenu(右键菜单)

    插件下载地址:http://www.trendskitchens.co.nz/jquery/contextmenu/jquery.contextmenu.r2.js压缩版:http://www.tre ...

  7. Linux下配置nfs并远程挂载

    nfs是网络文件系统,允许一个节点通过网络访问远程计算机的文件系统,远程文件系统可以被直接挂载到本地,文件操作和本地没有区别,如果是局域网的nfs那么io的性能也可以保证,下面就以CentOS 7.x ...

  8. 由易信界面——谈谈fragment 状态的保存

    看看我要实现的效果: 其实,这种左右界面切换保存布局方式,不只是易信界面这么用罢了.这更是大多数app布局的主流,而在android平台上面,随着谷歌大力推荐fragment的使用,用fragment ...

  9. android 微信听筒无声

    Dual talk项目sim卡插在卡2时.微信听筒无声: 第三方APP在听筒接听语音时会固定去设audio_mode为incall,而不会去管以下是sim1还是sim2在位. 而speechdrive ...

  10. (转)C#垃圾回收机制详解

    GC的前世与今生 虽然本文是以.net作为目标来讲述GC,但是GC的概念并非才诞生不久.早在1958年,由鼎鼎大名的图林奖得主John McCarthy所实现的Lisp语言就已经提供了GC的功能,这是 ...