Leftmost Digit(经典数学问题,对数求解)
2016-07-21 19:44
387 查看
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
Total Submission(s): 3372 Accepted Submission(s): 1482 |
[align=left]Problem Description[/align] Given a positive integer N, you should output the leftmost digit of N^N. |
[align=left]Input[/align] The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single positive integer N(1<=N<=1,000,000,000). |
[align=left]Output[/align] For each test case, you should output the leftmost digit of N^N. |
[align=left]Sample Input[/align]2 3 4 用科学计数法推规律: #include <iostream> #include <math.h> using namespace std; int main() { int t; while(cin>>t) { while(t--) { unsigned long n; cin>>n; double x=n*log10(n*1.0); x-=(__int64)x; int a=pow(10.0, x); cout<<a<<endl; } } return 0; } |
[align=left]Sample Output[/align]2 2Hint In the first case, 3 * 3 * 3 = 27, so the leftmost digit is 2. In the second case, 4 * 4 * 4 * 4 = 256, so the leftmost digit is 2. |
相关文章推荐
- Android应用程序窗口View的layout过程
- 【离散数学】最大元素、最小元素、极大元素、极小元素、上界、下界、最小上界(上确界)、最大下界(下确界)
- SDUT2132数据结构实验之栈二:一般算术表达式转换成后缀式(栈)
- 九大排序算法小结(复杂度)
- eclipse4.5在线安装Aptana3插件报错解决方案
- django学习之学前准备篇
- Vmware vSphere client手动更改mac地址
- 【解释】对用户透明=对用户隐蔽:关系模型的存取路径对用户透明
- POJ 1987 Distance Statistics 树分治
- 开头的是什么编码呢。浏览器可以解释它。如中国等同与中文"中国"?
- OTG
- 继承、实现、依赖、关联、聚合、组合
- 浅谈C语言中结构体的初始化
- var tensquared=(function(x) {return x*x;}(10)); //这是一个函数表达式 问:为什么花括号后面还有一个(10)的?而且整个句子用()扩起来?这个是什么表
- Java 用户登录系统
- 空心三角形
- C - Sacrament of the sum
- 《OpenCV2计算机视觉编程手册》2-8定义感兴趣区域(打水印)
- 腾讯信鸽自定义推送通知
- hdu5744 Keep On Movin(水)