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. java过滤特殊字符的正则表达式

    // 过滤特殊字符 public staticString StringFilter(String str) throws PatternSyntaxException { // 只允许字母和数字 / ...

  2. 通用的Bitmap压缩算法,进一步节约内存(推荐)

    前几天我写了一篇通过压缩Bitmap,减少OOM的文章,那篇文章的目的是按照imageview的大小来压缩bitmap,让bitmap的大小正好是imageview.但是那种算法的通用性比较差,仅仅能 ...

  3. Eclipse with ADT的安装和使用

    我们从安卓官方网站下载下来的eclipse是捆绑好了ADT的,所以不用自己安装插件. 我现在在这个目录下简历一个空的文件夹--virtual,用来来存放虚拟机. 然后,在我的电脑上右键->属性, ...

  4. [A类会议] 国内论文检索

    https://www.cn-ki.net/ http://www.koovin.com

  5. spring学习之@SessionAttributes

    一.@ModelAttribute 在默认情况下,ModelMap 中的属性作用域是 request 级别是,也就是说,当本次请求结束后,ModelMap 中的属性将销毁.如果希望在多个请求中共享 M ...

  6. hyper-v 用户无法再 创建外部配置存储 0x80070005

    windows server 2008R2 刚安装的hyper-v 重启过. 修改配置文件到d:\Hyper-V目录下, hyper-V 创建 服务器遇到错误 操作失败 创建外部配置存储:一般性拒绝访 ...

  7. maven-shade-plugin 入门指南

    1. Why? 通过 maven-shade-plugin 生成一个 uber-jar,它包含所有的依赖 jar 包. 2. Goals Goal Description shade:help Dis ...

  8. [转]HTTPS网络流量解密方法探索系列(一)

    前言 分析网络流量总是绕不开HTTPS,因其广泛使用甚至是强制使用逐渐被大众熟知,在保证其安全的同时也提高了对流量进行研究的难度.目前解析HTTPS协议的文章很多,有很多不错的文章可以带着入门,老实说 ...

  9. 再议FastReport.NET(转)

    之前说起过FastReport.NET这款报表工具的使用,但当时主要是从程序的角度,示例了在B/S架构下的相关使用,但报表终归还是要划到设计的范畴里来,毕竟能够将报表的内容展示在客户的眼前,这才是报表 ...

  10. Android -- 混淆

    混淆本质 把原来有具体含义的类名,变量名,方法名,修改成让人看不懂的名字,例如方法名getxx混淆为方法名a. Android Studio中的混淆 Android工程目录下有个文件,proguard ...