码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 1060 Leftmost Digit

时间:2014-08-29 17:31:59      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:style   os   io   log   sp   amp   on   size   c   

题解:利用log,先计算答案的log值,n=n*log10(n),然后,最高位就是小数部分幂还原的整数部分。

#include <cstdio>
#include <cmath>
int T;double n;
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%lf",&n);
        n=n*log10(n); n=n-(long long)n;;
        printf("%d\n",(int)pow(10,n));
    }return 0;
}

HDU 1060 Leftmost Digit

标签:style   os   io   log   sp   amp   on   size   c   

原文地址:http://www.cnblogs.com/forever97/p/3945123.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!