Tanky WooRSS

HDOJ 1060 Leftmost Digit

05 Jul 2010
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

今天论坛的ambition发了一个帖子:

http://www.cppleyuan.com/redirect.php?tid=1171&goto=lastpost#lastpost

看了下,感觉题目很不错,ambition的思路也很好。

涉及到了m^n,我感觉经常就是与log一起使用。

把题目做了下,ambition的代码已经足够了,贴出来分享:

 #include
#include
using namespace std;

int main()
{
    int n,m;
    double g;
    double h;
    for(cin>>n;n>0;n--)
    {
        cin>>m;
        g=m*log10((double)m);
        g=g-(long long)g;
        h=pow(10.,(double)g);
        cout<<(int)h<<endl;
    }
    return 0;
}