您的位置:首页 > 其它

hdu 1060 Leftmost Digit

2013-05-14 21:19 417 查看
/.......................................................................................................................................................................................................................\

简单的数学题,将y=N^N转换成y=10^(n*log10(n)),再利用科学

计数法,任意一个数都能用x*10^m表示(其中0<x<10的整数)

这里所求的最左边的数就转换成科学计数法x的值。

\......................................................................................................................................................................................................................../

#include<stdio.h>
#include <iostream>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<list>
#include<vector>
#pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;

int main()
{
int t,n;
double x,y,s;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
x=n*log10(n);
y=x-floor(x);//floor向下取整函数
s=pow(10,y);
printf("%d\n",(int)s);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hdu