Leftmost Digit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 21744    Accepted Submission(s): 8408

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.

Each test case contains a single positive integer N(1<=N<=1,000,000,000).

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的更多相关文章

  1. HDU 1060 Left-most Digit

    传送门 Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  2. HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用)

    Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  3. HDU 1060 Leftmost Digit (数论,快速幂)

    Given a positive integer N, you should output the leftmost digit of N^N.  InputThe input contains se ...

  4. HDU 1060 Leftmost Digit【log10/求N^N的最高位数字是多少】

    Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  5. HDU 1060 Leftmost Digit (数学/大数)

    Leftmost Digit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  6. 题解报告:hdu 1060 Leftmost Digit

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060 问题描述 给定一个正整数N,你应该输出N ^ N的最左边的数字. 输入 输入包含多个测试用例. ...

  7. HDU 1060 Leftmost Digit 基础数论

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060   这道题运用的是数学方法. 假设S=n^n.两边同时取对数,得到lgS=nlgn.即有S=10 ...

  8. HDU 1060 Leftmost Digit

    基本思路:(参考大神和加自己的思考) 考虑到此题需要输入这么大的数a,并且还的求aa,求出来会更大,更多位.当时考虑用大数方法求(数组实现),结果实现不行.看网上大神采用对数法,巧妙避开处理这么大的数 ...

  9. HDU 1060 Leftmost Digit (数学log)

    题意:给定一个数n,让你求出n的n次方的第一位数. 析:一看这个n快到int极限了,很明显不能直接做,要转化一下.由于这是指数,我们可以把指数拿下来. 也就是取对数,设ans = n ^ n,两边取以 ...

随机推荐

  1. 运行adb命令报错adb server version (31) doesn't match this client (39); killing...

    执行adb devices 报错 原因分析: 这个是socket 的端口被占用了,我这里是因为360手机助手占用了这个端口,所以其他的就不能够用了. 解决办法: 卸载了360的手机助手就可以了 首先 ...

  2. 20175209 《Java程序设计》第八周学习总结

    20175209 <Java程序设计>第八周学习总结 一.教材知识点总结 1.泛型 1.泛型类声明: 格式 class People<E> People是泛型类名称 E是泛型列 ...

  3. elasticsearch-head的安装

    elasticsearch-head是es的一个可视化的客户端插件,可以直接对ES进行增删改查操作,安装前需要先安装NODEJS: 安装: 1.到git上下载源代码: # git clone git: ...

  4. 关于Mac 系统mysql 乱码问题

    这是由于客户端和服务端的编码没有同一 首先我们先在终端连接mysql  连接方法 mysql -u 用户名  -p  即可 然后输入你的密码 这里就不多说了 然后我们输入   show variabl ...

  5. Java基础--常见计算机编码类型

    计算机编码指电脑内部代表字母或数字的方式,常见的编码方式有:ASCII编码,GB2312编码(简体中文),GBK,BIG5编码(繁体中文),ANSI编码,Unicode,UTF-8编码等. 1.ASC ...

  6. I/O模型系列之五:IO多路复用 select、poll、epoll

    IO多路复用之select.poll.epoll IO多路复用:通过一种机制,一个进程可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作. 应用:适用于针 ...

  7. [Android] TabLayout设置下划线(Indicator)宽度

    在使用TabLayout的过程中,为每个标签添加一个 下划线,但发现每个下划线的 宽度 都是一样的,例如会如下显示 这样很难看,所以必须进行调整后的效果如下: 看,这样不是非常和谐啦!~~ 实现方法很 ...

  8. work behind corp proxy

    =================================proxy 的写法=================================一般写法是: http://my.proxy.ad ...

  9. unix域数据报回射程序(不完整)

    一.服务器程序 int main(int argc, char **argv) { int sockfd; struct sockaddr_un servaddr, cliaddr; sockfd = ...

  10. PHP代码审计之命令注入

    命令注入 命令注入就是通过利用无验证变量构造特殊语句对服务器进行渗透. 注入的种类有很多,而不仅仅是SQL Injection. php常见注入有以下几种(常见:,常见!!): 命令注入 (Comma ...