hdu_1060_Leftmost Digit_201311071827-2
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11305 Accepted Submission(s): 4329
In the first case, 3 * 3 * 3 = 27, so the leftmost digit is 2. In the second case, 4 * 4 * 4 * 4 = 256, so the leftmost digit is 2.
//去掉整数部分(floor函数向下去整)得到10^(小数部分)最高位即是所求……
//x ^ x= 10^(x*lg(x))=10^(整数部分+小数部分) ;
#include <stdio.h>
#include <math.h> int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,t;
double a;
scanf("%d",&n);
a = log10((double)n);
a -= (int)a;
//n*a的结果可能很大,所以先减去整数部分再乘
a = n*a;
t = (int)a;
a -= t;
t = (int)pow(10.0,a);
printf("%d\n",t);
}
return ;
}
链接:http://www.cnblogs.com/hxsyl/archive/2012/09/04/2671068.html
总结:数学题,log的运用,掌握的不行,需多练习
hdu_1060_Leftmost Digit_201311071827-2的更多相关文章
随机推荐
- oracle 分页方法
我分享两种: 1.用rownum select * from (select p.* , rownum rn from t_premium p where rn<= page * 10) a ...
- J20170916-hm
スタイルシート 样式表 シール 封条 シート 纸片 マニフェスト 货单(Rails) ダイジェスト 消化,(Rails 附加哈希值) インタプリタ n. 解释者; 口译译员; [军事] 判读员; [自 ...
- Gym - 100920E 2010-2011 OpenCup IX Onsite, II Yandex Summer School E.Paint 状压DP
题面 题意:给你n(20)个点,m(40条边),让你给每条边染一种颜色,白色0元,红色2元,蓝色1元,现在要保证每一条白边相邻的有一条红边,问至少花多少 题解:刚开始想的时候,好像觉得只用染红色和白色 ...
- PHPExcel读取文件日期处理,含时分秒(Thinkphp)
我们使用PHPExcel读取excel文件后发现,时间都是类似于这样的数字:41890.620138889,那么如何将它处理成我们想要的2014-09-08 14:53:00这样格式的日期呢,看代码: ...
- JavaScript--输出内容(document.write)
document.write() 可用于直接向 HTML 输出流写内容.简单的说就是直接在网页中输出内容. 第一种:输出内容用“”括起,直接输出""号内的内容. <scrip ...
- Android 关于android.os.Build介绍
关于Build类的介绍 这个类为一个获取设备一些初始化信息的类,该类的主要信息都是通过一些static的字段获得: public static final String BOARD The name ...
- Android内存管理(12)*「实例」用Monitor 生成.hprof文件 并分析内存泄漏
参考 http://blog.csdn.net/xiaanming/article/details/42396507 基本步骤: 1,准备一个有内存泄漏的代码 2,如何发现内存泄漏 3,生成.hpro ...
- MYSQL创建用户和授权方法(测试mysql5.7)
一.创建用户: 命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说明:username - 你将创建的用户名, host - 指 ...
- 【转】 Java 集合系列07之 Stack详细介绍(源码解析)和使用示例
概要 学完Vector了之后,接下来我们开始学习Stack.Stack很简单,它继承于Vector.学习方式还是和之前一样,先对Stack有个整体认识,然后再学习它的源码:最后再通过实例来学会使用它. ...
- 联想 A5(L18011) 免解锁BL 免rec Magisk Xposed ROOT 救砖 ZUI 3.9.068
>>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...