hdu1060 数论

  没思路,看了网上各路好汉的分析之后略懂一二。

  任一个数m可以表示成10^(n+x),这里n为整数,x是小数。我们知道10^(n+x)=(10^n)*(10^x),前者的结果很明显,所以只要求出10^x,就可以知道m最左面的数值。

  (够shit)

   

#include <iostream>

 #include <math.h>

using namespace std;

 int main()

 {     double x,m,sum;  

   __int64 i,res,b;  

   __int64 n;   

  cin>>n; //如果换成scanf("%I64d",&n);会超时!!!!!

    while(n--)    

 {      

     scanf("%lf",&m);    //特么的刚开始一直写成ld

       x=m*log10(m);   

        b=(__int64)(x);      

       sum=x-b;       

       res=(__int64)(pow(10.0,sum));  //这里的pow(),里面的两个参数的类型要搞清楚

       printf("%I64d\n",res);

    }    

 return 0; }

原文地址:https://www.cnblogs.com/orangeblog/p/2233117.html