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. python多线程中join()方法和setDaemon()方法的区别

    """ join()方法:主线程A中,创建了子线程B,并且在主线程中调用了B.join()方法,那么主线程A会在调用的地方等待,直到子线程B完成操作后,才可以接着往下执行 ...

  2. 基于VUE框架 与 其他框架间的基本对比

    基于VUE框架的基本描述 与 其他框架间的基本对比 2018-11-03  11:01:14 A B React React 和 Vue 有许多相似之处,它们都有: 使用 Virtual DOM 提供 ...

  3. youtube上一些随手就来的牛逼颜色

    网页背景色: 白色背景 #f6f5f7:替代了原来的纯白,不那么刺眼,很和谐 黑色背景 #262626:一种很好看的黑色背景 其他颜色: 圆形边框线:#ddd;

  4. windows下安装oracle11g测试是否成功与监听器问题和网页控制台登录

    测试步骤1:请执行操作系统级的命令:tnsping orcl 测试步骤 2:请执行操作系统级的命令:sqlplus system/password@orcl 安装完oracle后要启动oracle服务 ...

  5. ubuntu下adb的使用以及开启黑域

    ubuntu使用adb开启黑域 刷了原生后经好友推荐, 黑域对于App的管控效果还是很不错的 adb的安装 此处顺带着就把fastboot也安装了 sudo apt update sudo apt i ...

  6. 阿里百川SDK初始化失败 错误码是203

    由idea换到Androidstudio 了,结果报这个错,之前好好的啊!!! 设置问题:

  7. SDOI 2019 R1 摸鱼记

    Day -1 学文化课第一天,也是这周最后一天. 昨晚 mxl 让我们今天下午放学走,大概六点的样子,感觉良好. 早读班主任送来请假条,跟我讲中午放学走??? 很懵逼,以为班主任口胡了,问了一句&qu ...

  8. EF提交插入数据catch捕获具体异常方法

    try { db.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder errors = new String ...

  9. CPU或以太网模块重启DHCP请求

    最近,带了一个实习生,一天: 他:师傅,PLC如何首次分配IP地址啊? 我:不是教过你了吗? 他:我怎么用BOOTP软件,半天没有反应啊? 我:..... 原来,他做实验的CPU已经被分配IP地址了, ...

  10. springboot-文件上传xls及POI操作Excel

    1.pom导入依赖文件 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-o ...