您的位置:首页 > 其它

HDU 1060 Leftmost Digit

2013-06-18 21:13 471 查看
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1060

取对数,然后求小数部分,然后求幂,ok

代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std;

const int N=1001;
typedef long long LL;

int main()
{
int i,j,n,T;
cin>>T;
while(T--)
{
scanf("%d",&n);
double t=n*log10(double(n));//取对数
LL a=(LL)t;//整数部分表示位数-1
t-=a;//小数部分
t=pow(10.0,t);
a=(LL)t;
while(a==0)
{
t*=10;
a=(LL)t;
}
printf("%d\n",a);
}

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