Project Euler:Problem 63 Powerful digit counts
2015-07-14 17:04
260 查看
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
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; }
相关文章推荐
- PX4/Pixhawk---uORB深入理解和应用
- DATA GUARD(笔记加转载加理解--未完,整理中
- LR socket接收数据 标准函数,结构体解析
- xamarin.Froms 框架一览(二)
- Win8.1操作系统快捷键驱动的设置方法
- 队列
- NYOJ 824 Greedy Mouse
- Google Java编程风格指南中文版
- 内存定位和对齐
- 【j2ee spring】43、巴巴运动网添加,编辑,上架,下架产品样式
- 学习mongoDB的一些感受(转自:http://blog.csdn.net/liusong0605/article/details/11581019)
- MaxScript Reference导读
- sas与java关于运算的一些转换
- 递归是一种算法结构,回溯是一种算法思想
- fread和fwrite用法小结
- 使用 Redis 共享 Session 会话
- 【Java】给定两个32位的整数N与M,以及表示比特位置的i与j。编写一个方法,将M插入N,使得M从N的第 j 位开始,到第 i 位结束。
- Android中Socket大文件断点上传
- 大数加减
- Android开发数据相关