HDU1060】的更多相关文章

Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) 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 l…
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2519 Accepted Submission(s): 1101   Problem Description Given a positive integer N, you should output the leftmost digit of N^N.   In…
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14696    Accepted Submission(s): 5660 Problem Description Given a positive integer N, you should output the leftmost digit of N^N.…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1060 题目描述:求N的N次方的第一位. 思路: 第一次做这种类型的题目,学到了如何运用对数. 首先推导下述公式 k的以10为底的对数值必定是A.B的形式,A为结果的整数部分,B为小数部分 这里求nn的首位只需要求出A.B = Nlog(N),然后取小数位即可,因为10A并没有什么用,只要算出100.B 就算出了首位数字.这种方法可以用来求前i位.(i数值要小,因为运算精度有限) #include<…
#include <bits/stdc++.h> using namespace std; int main() { int n; long long x; double t,ans; cin>>n; while(n--) { cin>>x; t=x*log10(x); ans=pow(,t-(long long)t); cout<<(int)ans<<endl; } ; } 公式看的题解,根本想不到,数据类型转换也没有想到,还以为是用快速幂解题…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1061 思路:结论:a=10^(N*lg(N) - [lg(N^N)]); 证明:如果一直a是结果,则a*10^x=n^n; 对等式两端去对数 lg(a*10^x)=lg(n^n); x+lga = n*lgn; 所以:a=10^(n*lgn-x); 只要再求出x就可以了,x是n^n的位数,因此,x=[lg(n^n)],[ ]表示向下取整. 所以 a=10^(N*lg(N) - [lg(N^N)]);…
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16762    Accepted Submission(s): 6643 Problem Description Given a positive integer N, you should output the leftmost digit of N^N.…