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的更多相关文章
随机推荐
- 41. extjs--combobox下拉列表的triggerAction
转自:https://icrwen.iteye.com/blog/939247 一般combobox的store先load加载数据,然后combobox的mode设置为local,则不会每次下拉列表都 ...
- CentOS Linux VPS桌面环境一键安装包
- MyBatis高级查询 一对一映射
drop database if exists simple; create database simple; use simple; drop table if exists sys_user; c ...
- zabbix监控kafka消费
一.Kafka监控的几个指标 1.lag:多少消息没有消费 lag=logsize-offset 2.logsize:Kafka存的消息总数 3.offset:已经消费的消息 Kafka管理工具 介绍 ...
- 写出更好的 JavaScript 条件语句
1. 使用 Array.includes 来处理多重条件 // 条件语句 function test(fruit) { if (fruit == 'apple' || fruit == 'strawb ...
- 研磨JavaScript系列(三):函数的魔力
JavaScript的代码中就只有function一种形式,function就是函数的类型.在其他的编程语言中可能还存在Procedure或者是method等代码概念,在JavaScript中只有fu ...
- hibernate annotation 生成uuid主键
JPA标准方式下,不可以生成uuid类型的主键,但是hibernate提供了一些方式生成uuid主键,具体如下: 1.主键生成器 @GeneratedValue(generator=" ...
- 【深度学习笔记】(一)Mac下TensorFlow安装及环境搭建
本文由@ray 出品,转载请注明出处. 文章链接:http://www.cnblogs.com/wolfray/p/7828903.html 在学习了一段时间台大李宏毅关于deep learning ...
- PAT甲级1016Phone Bills
#include<iostream> #include<cstdio> #include<cstdlib> #include<vector> #incl ...
- c指针之内存释放
// 1.正常使用包含指针的结构体 // 2.正常使用元素类型为指针的vector #include<string.h> #include<stdio.h> #include& ...