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,两边取以 ...
随机推荐
- ios app架构设计系统文章
三. iOS应用架构谈(三):网络层设计方案(上) http://www.infoq.com/cn/articles/ios-app-arch-3-1?utm_source=infoq&utm ...
- 11Mybatis_mybatis开发Dao的方法
在介绍开发Dao的方法之前先介绍下SqlSession. 1.先介绍一下SqlSessionFactoryBuilder:通过SqlSessionFactoryBuilder创建会话工厂SqlSess ...
- int 与Integer的用法与区别
1.int是基本类型,直接存取数值,Integer是对象,用一个引用指向这个对象. 2.java中的数据类型分为基本数据类型和复杂数据类型,int是前者,Integer是后者(也就是一个类). 3.初 ...
- [MetaHook] Load large texture from model
We need hook "GL_LoadTexture" engine function. GL_LOADTEXTURE_SIG from hw.dll(3266) engine ...
- 20145215《Java程序设计》第4周学习总结
20145215<Java程序设计>第四周学习总结 教材学习内容总结 继承与多态 继承 继承作为面向对象的第二大特征,基本上就是避免多个类间重复定义共同行为.即当多个类中存在相同属性和行为 ...
- 数据挖掘系列(5)使用mahout做海量数据关联规则挖掘
上一篇介绍了用开源数据挖掘软件weka做关联规则挖掘,weka方便实用,但不能处理大数据集,因为内存放不下,给它再多的时间也是无用,因此需要进行分布式计算,mahout是一个基于hadoop的分布式数 ...
- 如何用Android Studio打多包名APK
问题:项目中不同的分发渠道可能需要打包多种APK(同样的代码),包名可能是不一样的,如果一个一个修改包名重新编apk是很麻烦,可以参考下列步骤在Android Studio上操纵Gradle来打包不同 ...
- 删除 windows 下 node_modules 过深的目录
本文同步自我的个人博客:http://www.52cik.com/2015/11/13/node-modules-del.html 说到 node 的模块,确实既好用又蛋疼.相信无数人吐槽 node_ ...
- SVN技术交流提纲
SVN技术交流提纲:http://lazio10000.github.io/tech/SVN/#/bored
- css为什么要用悬浮
如果这个100px的宽度是一个Img,横内元素.右边也是横内元素的话和块级元素是不同的. 2.文字环绕图片. div下有个img然后有个span标签 img最好悬浮,悬浮虽然说脱离文档,但是还是占空间 ...