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 ...
随机推荐
- 专业术语:闭包、网站优化 Gzip 服务器端文件压缩
1, 闭包:http://baike.baidu.com/view/648413.htm 2, 网站优化 Gzip 服务器端文件压缩 http://baike.baidu.com/view/96662 ...
- display:inline-block;在各浏览器下的问题和终极兼容办法
display:inline-block;在各浏览器下的问题和终极兼容办法 一.IE 5.5.6.7 .8(Q)中display:inline-block;失效 兼容办法: IE 5.5.6.7 .8 ...
- 项目笔记:导出XML和导出全部XML功能
前台代码: //导出一条Xml function btn_createXml(){ var title =$("#editButton").attr("title&quo ...
- 转: Servlet-jsp从入门到精通 1~5
评注: 来自简书,内容很简要. http://www.jianshu.com/p/d718a5f4a850 (一) http://www.jianshu.com/p/06efc32c10cf (二 ...
- EffectiveJava(4)通过私有构造器强化不可实例化的能力
通过私有构造器强化不可实例化的能力 原理:只有当类不包含显式的构造器时,编译器才会生成缺省的构造器,因此只要让这个类包含私有构造器,他就不能被实例化 这种方式下,子类没有可访问的超类构造器可调用 // ...
- mother's day.py 母亲节
今天母亲节,写了个程序.抓取一个站点的母亲节祝福短信.实现自己主动翻页, 道友们也能够甲乙改造.比方加上节日简洁,time()模块. . . 一起分享吧 # -*- coding: cp936 -*- ...
- 51nod 125乘法逆元 (扩展欧几里得)
给出2个数M和N(M < N),且M与N互质.找出一个数K满足0 < K < N且K * M % N = 1,假设有多个满足条件的.输出最小的. Input 输入2个数M, N中间用 ...
- 懒人学习automake, Makefile.am,configure.ac(转)
已经存在Makefile.am,如何生成Makefile? 步骤: [root@localhost hello]# autoscan .///在当前文件夹中搜索 [root@localhost hel ...
- TCP/IP详解 卷一(第十一章 UDP:用户数据报协议)
UDP是一个简单的面向数据报的运输层协议. UDP不提供可靠性:它把应用程序传给IP层的数据发送出去,但是并不保证它们能到达目的地. UDP首部的个字段如下图所示
- C# DataTable 转 List(大家进来讨论讨论)
C# DataTable 转 List 方法,网上有好多,之前也收集了,感觉这个也不错,重要是自己要领会这里面的代码含义. 接不来我就把代码贴出来分享一下,大家觉得如果不好,请留言我,我来改进. us ...