Leftmost Digit(hdu1060)(数学题)
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16762 Accepted Submission(s): 6643
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
Sample Output
In the first case, 3 * 3 * 3 = 27, so the leftmost digit is 2.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std; int main()
{
int t;
int n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
double temp=n*log10(n*1.0);
double res=temp-floor(temp);
printf("%d\n",(int)pow(10.0,res));
}
return ;
}
Leftmost Digit(hdu1060)(数学题)的更多相关文章
- HDU 1060 Left-most Digit
传送门 Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- hdu acmsteps 2.1.8 Leftmost Digit
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- <hdu - 1600 - 1601> Leftmost Digit && Rightmost Digit 数学方法求取大位数单位数字
1060 - Leftmost Digit 1601 - Rightmost Digit 1060题意很简单,求n的n次方的值的最高位数,我们首先设一个数为a,则可以建立一个等式为n^n = a * ...
- Leftmost Digit
Problem Description Given a positive integer N, you should output the leftmost digit of N^N. Input ...
- HDU 1060 Leftmost Digit
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- Leftmost Digit(数学)
Description Given a positive integer N, you should output the leftmost digit of N^N. Input The inp ...
- 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 ...
随机推荐
- 针对ecshop错误404页面的优化
在ecshop系统当中,比如你随意将商品详细页面的地址中的ID修改为一个不存在的商品ID,ecshop会自动跳转到首页.ecshop在这方面做得非常的差,甚至导致了很多的站不被搜索引擎收录.最模板提供 ...
- [WCF菜鸟]什么是WCF
一.概述 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows通讯接口,它是.NET框架的一部分.由 .NE ...
- native method与so中function的关联
在Android中,可以通过JNI的方式来调用和访问用C/C++实现的代码,这些代码以SharedLibrary的方式存在于so中.从Java Code到Native Code的一般使用过程为: 在J ...
- 【转载】深入理解JVM性能调优
性能问题无非就这么几种:CPU.内存.磁盘IO.网络.那我们来逐一介绍以下相关的现象和一些可能出现的问题. 一.CPU过高. 查看CPU最简单的我们使用任务管理器查看,如下图所示,windows下使用 ...
- linux 文件&文件夹大小排序
按照当前文件夹的文件大小排序: ls -l | sort -k 5 -n -r 其中 sort 的几个参数: -k 5: 表示使用第五列字段排序, 当需要按照多个字段排序时, 可使用多个 -k 参数, ...
- .mata. _root_ (转)
HRegionServer 里面存放了很多的HRegion,而且每一个HRegion都有一个唯一标识(表名+开始主键+唯一ID),这个唯一标识符在每一个HRegion中都有存储. .mata.表存的数 ...
- chrome使用
本文转载于http://www.cnblogs.com/tester-l/p/5743031.html Chrome调试工具各个工具的作用: Element Elements板块你可以看到整个页面的D ...
- GridControl 二次封装,自定义颜色样式风格
1.自定义颜色格式,分组,筛选 1.封装类 必须引用类库 using System; using System.Collections.Generic; using System.Linq; usin ...
- FormatFloat
http://www.delphibasics.co.uk/RTL.asp?Name=FormatFloat 1 function FormatFloat ( const Formatting : ...
- MQTT--topic
1.topic 定阅与发布必须要有主题,只有当定阅了某个主题后,才能收到相应主题的payload,才能进行通信. 2. 主题层级分隔符—“/” 主题层级分隔符使得主题名结构化.如果存在分隔符,它将 ...