hdu 1060 Leftmost Digit
2013-09-25 23:05
501 查看
题意:求n^n的第一个数字是多少?
题解:c=log10(n^n)=nlog10(n),a是c的整数部分,b是c的小数部分,a+b=c;n^n=10^c=10^a*10^b,所以10^b=10^c/10^a=10^(c-a),
10^b的整数部分是一位,就是答案了。
耗时:0MS
题解:c=log10(n^n)=nlog10(n),a是c的整数部分,b是c的小数部分,a+b=c;n^n=10^c=10^a*10^b,所以10^b=10^c/10^a=10^(c-a),
10^b的整数部分是一位,就是答案了。
耗时:0MS
#include <cstdio> #include <cstring> #include <cmath> #include <queue> #include <iostream> #include <algorithm> using namespace std; #define LL __int64 int main() { int T; scanf("%d",&T); while(T--) { double s; int n; scanf("%d",&n); s=n*log10(1.0*n); s-=(LL)s;//强制转换成整数可能会超int printf("%d\n",(int)pow(10.0,s)); } return 0; }
相关文章推荐
- HDU 1060 Leftmost Digit
- HDU 1060 Leftmost Digit(数论)
- HDU 1060 Leftmost Digit(数学)
- hdu 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- HDU 1060 Leftmost Digit (数学log)
- hdu 1060 Leftmost Digit
- HDU:1060 Leftmost Digit(数学)(水)
- HDU 1060 Leftmost Digit
- HDU 1060 Leftmost Digit 数学题
- hdu 1060 Leftmost Digit
- HDU 1060 - Leftmost Digit
- hdu 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- hdu--1060--Leftmost Digit
- HDU--1060--Leftmost Digit
- HDU 1060 Leftmost Digit
- HDU 1060.Leftmost Digit【重点在分析】【格式【晕】】【8月31】【记录】