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. 闪电侠第四季/全集The Flash迅雷下载

    闪电侠第四季>(The Flash Season 4)是DC娱乐和华纳联手CW电视台制作的真人超级英雄系列剧,是美剧<闪电侠>系列的第四季. 该季于2017年10月10日在美国CW电 ...

  2. 简析Window、Activity、DecorView以及ViewRoot之间的错综关系

    一.职能简介 Activity Activity并不负责视图控制,它只是控制生命周期和处理事件.真正控制视图的是Window.一个Activity包含了一个Window,Window才是真正代表一个窗 ...

  3. Chrome快捷键大全

    Chrome上我基本不怎么用快捷键,但是发现了切换标签页的快捷键后觉得十分好用,所以就分享如下. 切换上一个标签:Ctrl+PgUp 切换下一个标签:Ctrl+PgDn 打开新标签页:Ctrl+T 通 ...

  4. 自定义View,随着手指运动的小球

    这个实例是自定的view的初步介绍,要设计的是一个随着手指运动的小球.原理是随时获取手指的坐标,然后在这个坐标上面实时改变自定义view的坐标.这个view仅仅是画了一个圆形而已. 自定义的view ...

  5. Java(C#)基础差异-语法

    1.long类型 Java long类型,若赋值大于int型的最大值,或小于int型的最小值,则需要在数字后加L或者l,表示该数值为长整数,如long num=2147483650L. 举例如下: p ...

  6. [转]ThinkPHP的CURD易忽视点小结

    转自: http://www.oschina.net/code/snippet_2285640_44437. 1.使用对象的方法插入数据 D用法. $Form = D('Form'); $data[' ...

  7. [转]IOS下如何判断机器是否越狱

    转自: http://blog.csdn.net/kaizi318/article/details/9135385 关于判断iPhone是否是jailbreak机器,可参考如下代码: static c ...

  8. 第二章 IOC + AOP 底层原理

    <精通Spring4.x 企业应用开发实战>读书笔记 一.概念 IOC: 假设B类调用了A类,那么A类的对象的创建是由B类来实现: IOC是指将A对象的创建由容器来完成,并且将创建好的对象 ...

  9. Go语言之进阶篇实现并发聊天功能

    1.并发聊天服务器原理分析 2.并发聊天室 功能: 广播消息.广播上线. 查询在线用户.修改用户名.用户主动退出.超时处理 示例: package main import ( "fmt&qu ...

  10. 一个简易Asp.net网站日志系统

    前不久在网站上看到了网站日志访问记录组件UserVisitLogsHelp开源了! 这篇博客感觉还不错,就把源码download了下来,学习一下,发现里面的代码书写和设计并不是很好,于是自己改了改.自 ...