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 ...
随机推荐
- Ubuntu14.04终端主机名+用户名修改配色方案
首先打开终端:输入指令ls -a 然后输入指令:vi .bashrc 先按下字母A,进入编写: 在文档最后一行添加: PS1='${debian_chroot:+($debian_chroot)}\[ ...
- hadoop错误总结
1.hadoop3: mkdir: cannot create directory `/usr/local/hadoop/bin/../logs': Permission denied 把所有Data ...
- python实现将文件夹内所有txt文件合并成一个文件
新建一个文件夹命名为yuliao,把所有txt文件放进去就ok啦!注意路径中‘/’,windows下路径不是这样. #coding=utf-8 import os #获取目标文件夹的路径 filed ...
- 转: Servlet-jsp从入门到精通 1~5
评注: 来自简书,内容很简要. http://www.jianshu.com/p/d718a5f4a850 (一) http://www.jianshu.com/p/06efc32c10cf (二 ...
- 【原创】关于bug反正出现的问题可能
bug修正的问题:1. xib问题.2. 模块不清同时修改.3. svn代码合并的修改熟悉程度.4. 禁止全局格式化代码.
- hdu 4512 吉哥系列故事——完美队形I(最长公共上升自序加强版)
首先要去学习最长公共上升子序列LCIS.然后是对n*n效率的算法进行优化,这里要注意的是能够求出来的序列中间能够有一个最高的.刚開始将输入的数组进行逆置,写下来发现这可能存在问题. 只是详细是什么也没 ...
- Assets 读取assets中的文件
res/raw和assets的相同点: 1.两者目录下的文件在打包后会原封不动的保存在apk包中,不会被编译成二进制. res/raw和assets的不同点:1.res/raw中的文件会被映射到R.j ...
- kali渗透综合靶机(一)--Lazysysadmin靶机
kali渗透综合靶机(一)--Lazysysadmin靶机 Lazysysadmin靶机百度云下载链接:https://pan.baidu.com/s/1pTg38wf3oWQlKNUaT-s7qQ提 ...
- 谈谈PHP网站的防SQL注入
SQL(Structured Query Language)即结构化查询语言.SQL 注入,就是把 SQL 命令插入到 Web 表单的输入域或页面请求参数的查询字符串中,在 Web表单向 Web 服务 ...
- JQuery DataTables学习
1.Datatables简单介绍 DataTables是一个jQuery的表格插件.这是一个高度灵活的工具,根据的基础逐步增强,这将添加先进的互动控制.支持不论什么HTML表格. 主要特点: 自己主动 ...