HDU 1060 Left-most Digit
传送门
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15305 Accepted Submission(s): 5937
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
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.
#include <bits/stdc++.h>
using namespace std; int main(){
int T;
scanf("%d", &T);
for(int n; T--; ){
scanf("%d", &n);
double t=log10(n)*n;
printf("%d\n",(int)pow(, t-floor(t)));
}
}
Tips
<cmath>内常用函数:
pow
exp
log 自然对数
log10 常用对数
log2 以2为底的对数
floor
ceil
HDU 1060 Left-most Digit的更多相关文章
- 题解报告:hdu 1060 Leftmost Digit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060 问题描述 给定一个正整数N,你应该输出N ^ N的最左边的数字. 输入 输入包含多个测试用例. ...
- HDU 1060 Leftmost Digit 基础数论
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060 这道题运用的是数学方法. 假设S=n^n.两边同时取对数,得到lgS=nlgn.即有S=10 ...
- HDU 1060 Leftmost Digit
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用)
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1060 Leftmost Digit (数论,快速幂)
Given a positive integer N, you should output the leftmost digit of N^N. InputThe input contains se ...
- HDU 1060 Leftmost Digit【log10/求N^N的最高位数字是多少】
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1060 Leftmost Digit (数学/大数)
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1060 Leftmost Digit
基本思路:(参考大神和加自己的思考) 考虑到此题需要输入这么大的数a,并且还的求aa,求出来会更大,更多位.当时考虑用大数方法求(数组实现),结果实现不行.看网上大神采用对数法,巧妙避开处理这么大的数 ...
- HDU 1060 Leftmost Digit (数学log)
题意:给定一个数n,让你求出n的n次方的第一位数. 析:一看这个n快到int极限了,很明显不能直接做,要转化一下.由于这是指数,我们可以把指数拿下来. 也就是取对数,设ans = n ^ n,两边取以 ...
随机推荐
- Android 可拖拽的GridView效果实现, 长按可拖拽和item实时交换
转帖请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/17718579),请尊重他人的辛勤劳动成果,谢谢! 在And ...
- mysqli_stmt预处理类的使用
- ArcGis 中MapControl 框选
void mCtrl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) ...
- 1976 Queen数列
1976 Queen数列 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description 将1到N的整数数列(1 ...
- Bitbucket免费的私有仓库
1.官网 https://bitbucket.org/ 2.介绍 知乎:http://www.zhihu.com/question/20053312 建议同时用Bitbucket和Github,理由如 ...
- 【Windows phone 8】欢迎引导页面02
[目标]前一篇文章已经实现了图片的切换,这里需要限制pivot的循环滚动. [思路]通过手势事件,对第一张,最后一张图片处加以限制 [前台] 在pivot处加上 <toolkit:Gesture ...
- [转]Ubuntu 用vsftpd 配置FTP服务器
FROM : http://www.cnblogs.com/CSGrandeur/p/3754126.html 网上的文章好难懂啊..只想要简单粗暴,弄好能用就行啊,复杂的以后研究不行吗...折腾好久 ...
- 地图投影——高斯-克吕格投影、墨卡托投影和UTM投影
地图投影(Map Projection) http://baike.baidu.com/view/94066.htm 概念: 地图投影是把地球表面的任意点,利用一定数学法则,转换到地图平面上的理论和方 ...
- MySQL server has gone away的解决方法
用Python写了一个http服务,需要从mysql读数据库,第一天还好好的,第二天突然不行了.报错如下: pymysql.err.OperationalError: (2006, 'MySQL se ...
- scrapy 代理
说明: 本文参照了官网文档,以及stackoverflow的几个问题 概要: 在scrapy中使用代理,有两种使用方式 使用中间件 直接设置Request类的meta参数 方式一:使用中间件 要进行下 ...