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 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的更多相关文章
- Project Euler 63: Powerful digit counts
五位数\(16807=7^5\)也是一个五次幂,同样的,九位数\(134217728=8^9\)也是一个九次幂.求有多少个\(n\)位正整数同时也是\(n\)次幂? 分析:设题目要求的幂的底为\(n\ ...
- 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 ...
- Project Euler:Problem 33 Digit cancelling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- Project Euler:Problem 55 Lychrel numbers
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindr ...
- 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 ...
- 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 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 89 Roman numerals
For a number written in Roman numerals to be considered valid there are basic rules which must be fo ...
随机推荐
- JS --- 三目运算符
1.什么是三目运算:(布尔表达式 ? 值0:值1;) 5>3?alert('5大'):alert('3大'); 即 if(5>3){alert('5大')}else{alert('3 ...
- ifram 取父窗体的URL地址
var url=''; try { url = window.top.document.referrer ; } catch(M) { if (window.parent) ...
- HTTPS安全证书介绍
IIS配置web SSL 安全证书Https访问 From : http://cao416451347ming.blog.163.com/blog/static/1154556162010217441 ...
- django数据模型中 null=True 和 blank=True 有什么区别?
null 如果为 True , Django 在数据库中会将空值(empty)存储为 NULL .默认为 False . blank 设置字段是否可以为空,默认为False(不允许为空) 和null的 ...
- Win2008建立域时administrator账户密码不符合要求
在win2008中建立域时,有时会出现administrator账户密码不符合要求的现象,报错会说明目前本地administrator账户不需要密码.这是什么原因造成的呢?原来,目前的2008镜像在网 ...
- Shell变量while循环内改变无法传递到循环外
转自: https://blog.csdn.net/shawhe/article/details/65631543 今天刷Leecode(192 Word frequency)时,遇到一个shell语 ...
- go语言之进阶篇空接口
1.空接口 示例: package main import "fmt" func xxx(arg ...interface{}) { } func main() { //空接口万能 ...
- Netty和Tomcat的区别、性能对比
一.Netty和Tomcat有什么区别? Netty和Tomcat最大的区别就在于通信协议,Tomcat是基于Http协议的,他的实质是一个基于http协议的web容器,但是Netty不一样,他能通过 ...
- linux kernel系列四:嵌入式系统中的文件系统以及MTD
本节介绍File System和MTD技术 一 FS 熟知的FS有ext2,3,4.但是这些都是针对磁盘设备的.而ES中一般的存储设备为Flash,由于Flash的特殊性: Flash存储按照Bloc ...
- 转:在centos安装与启动mysql
一. 下载与安装过程相录详细 相当详细推荐.digitalocean.com 这个网站的东西,很详细,很专业. https://www.digitalocean.com/community/tutor ...