hdu1060 Leftmost Digit
来源:互联网 发布:淘宝怎查被隐形降权 编辑:程序博客网 时间:2024/04/29 22:20
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14951 Accepted Submission(s): 5774
Problem Description
Given a positive integer N, you should output the leftmost digit of N^N.
Input
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).
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the leftmost digit of N^N.
Sample Input
234
Sample Output
22HintIn 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.
Author
Ignatius.L
Recommend
We have carefully selected several similar problems for you: 1061 1071 1573 1066 1005
说实话 这道题我不会做、、当我看到n的范围那么大 就想着会不会有规律。可n又太大。不知道怎么办
就百度了
m=n^n,两边同时取对数log10,变为log10(m)=n*log10(n);继续化简为m=10^(n*log10(n)),因为10的任意整数次方
首位都是1,于是首位就和n*log10(n)的小数部分有关了。
还有这样的方法对于2来说是不对的。。不
#include <stdio.h>#include <math.h>int main(){int ncase;double n,ans;scanf("%d",&ncase);while(ncase--){scanf("%lf",&n);ans=log10(n);ans=(ans-(int)ans)*n;ans=ans-(int)ans;printf("%d\n",(int)pow(10,ans));}return 0;}
0 0
- hdu1060 Leftmost Digit(转载)
- hdu1060-Leftmost Digit
- HDU1060--Leftmost Digit
- HDU1060 Leftmost Digit 【数学】
- Leftmost Digit hdu1060
- HDU1060 Leftmost Digit
- hdu1060 Leftmost Digit
- hdu1060 Leftmost Digit
- HDU1060 Leftmost Digit
- HDU1060 Leftmost Digit
- hdu1060 Leftmost Digit
- HDU1060 Leftmost Digit
- HDU1060 Leftmost Digit (数学推导)
- HDU1060:Leftmost Digit(数论)
- Leftmost Digit
- Leftmost Digit
- Leftmost Digit
- Leftmost Digit
- Windows内核编程基础篇之获取当前系统时间
- web_reg_find和web_find的区别
- PhotoView源码分析(1)
- 各种杂项组件(3)之--CalendarView(日历视图)、DatePicker/TimePicker(日期、时间选择器)、NumberPicker(数值选择器)
- PAT 1081. Rational Sum (20)
- hdu1060 Leftmost Digit
- JohnsonTroter 排列生成算法
- #牛客#代码实现:二叉树的序列与反序、逆栈、链表回文、MaxTree
- hdu 1013 Digital Roots(模拟 || 数论)
- 数据库锁机制
- lintcode-硬币排成一条线
- 迭代器模式(二):迭代器模式概述
- 面试题_64——数据流中的中位数
- JAVA面试(未完)