HDU 1060 Leftmost Digit
Leftmost Digit
|
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Given a positive integer N, you should output the leftmost digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Output For each test case, you should output the leftmost digit of N^N. Sample Input 2 3 4 Sample Output 2 2 Hint 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<iostream>
#include<string.h>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
ll T;
double n;
scanf("%lld",&T);
while(T--){
scanf("%lf",&n);
cout<<(ll)pow(10,n*log10(n)-(ll)(n*log10(n)))<<endl;
}
return 0;
}
HDU 1060 Leftmost Digit的更多相关文章
- HDU 1060 Left-most Digit
传送门 Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 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
题目链接: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
基本思路:(参考大神和加自己的思考) 考虑到此题需要输入这么大的数a,并且还的求aa,求出来会更大,更多位.当时考虑用大数方法求(数组实现),结果实现不行.看网上大神采用对数法,巧妙避开处理这么大的数 ...
- HDU 1060 Leftmost Digit (数学log)
题意:给定一个数n,让你求出n的n次方的第一位数. 析:一看这个n快到int极限了,很明显不能直接做,要转化一下.由于这是指数,我们可以把指数拿下来. 也就是取对数,设ans = n ^ n,两边取以 ...
随机推荐
- Apache Flink教程
1.Apache Flink 教程 http://mp.weixin.qq.com/mp/homepage?__biz=MzIxMTE0ODU5NQ==&hid=5&sn=ff5718 ...
- Excel中最精确的计算年龄的公式
身份证算年龄 假设A1是身份证号所在单元格 =IF(MONTH(NOW())<INT(MID(A1,11,2)),INT(YEAR(NOW())-INT(MID(A1,7,4)))-1,IF(M ...
- Multi-View 3D Reconstruction with Geometry and Shading——Part-2
From PhDTheses Multi-View 3D Reconstruction with Geometry and Shading 我们的主要目标是只利用图像中的信息而没有额外的限制或假设来得 ...
- opencv + cuda编译
#获取最新代码git clone "https://github.com/opencv/opencv.git" #build目录mkdir buildcd build #使用ccm ...
- Promise的源码实现(完美符合Promise/A+规范)
Promise是前端面试中的高频问题,我作为面试官的时候,问Promise的概率超过90%,据我所知,大多数公司,都会问一些关于Promise的问题.如果你能根据PromiseA+的规范,写出符合规范 ...
- JGUI源码:实现蒙版层显示(18)
有的时候需要显示一个蒙版层,蒙版层显示的主要原理是在指定元素比如div上创建一个子元素div,设置absolute.宽高100%.设置z-index置于顶层,设置半透明效果,fadein,fadeou ...
- XGBboost 特征评分的计算原理
xgboost是基于GBDT原理进行改进的算法,效率高,并且可以进行并行化运算,而且可以在训练的过程中给出各个特征的评分,从而表明每个特征对模型训练的重要性, 调用的源码就不准备详述,本文主要侧重的是 ...
- 第四周WordCount优化
一.GitHub地址 https://github.com/kawoyi/Advanced-WordCounter最终由组长整合的组长github 二.psp表格 三.个人模块及实现 我负责的是输入模 ...
- mysql—增删改查语句总结
关于MySQL数据库——增删改查语句集锦 一.基本的sql语句 CRUD操作: create 创建(添加) read 读取 update 修改 delete 删除 .添加数据 ,'n001','201 ...
- 关于dfs
DFS 关于dfs,我的理解就是深度搜索,找到所有与入口相连的路径,可以用于迷宫求出口,利用递归的思想,进行搜索返回所有值. 比如,给你两个值分别表示迷宫的长和宽,迷宫有一个入口,一个出口,判断能否从 ...