您的位置:首页 > 其它

hdu1060 Leftmost Digit

2015-08-17 16:59 232 查看
题目(http://acm.hdu.edu.cn/showproblem.php?pid=1060)

求n^n最右侧的数,设m=n^n,两边取对数m=10^(n*log10(n)),由于10的正整数次方都和个位没关系,只与小数部分有关。

#include <iostream>
#include <math.h>
using namespace std;

int main()
{int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
double tmp=n*log10(double(n));
double power=tmp-floor(tmp);
int ans=pow(10.0,power);
cout<<ans<<endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: