Leftmost Digit

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

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
 
 
分析:求n^n的最前一位数。有log10(n^n)=n*log10(n)=c,令a为c的整数部分,b为c的小数部分,则n^n=10^c=10^a*10^b,即10^b=10^(c-a),10^b的整数部分只有一位就是n^n的最左位。
 
 #include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
using namespace std;
#define INF 100000
typedef long long ll;
const int maxn=; int main()
{
int t;
scanf("%d",&t);
double sum;
while(t--){
ll n;
scanf("%I64d",&n);
sum=n*log10(n);
sum-=(ll)sum;
printf("%I64d\n",(ll)pow(10.0,sum));
}
return ;
}

HDU-1060(简单数学)的更多相关文章

  1. HDU 5073 Galaxy (2014 Anshan D简单数学)

    HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description G ...

  2. hdu 2200 Eddy's AC难题(简单数学。。)

    题意: N个人,每个人AC的题数都不一样. Eddy想从中选出一部分人(或者全部)分成两组.必须满足第一组中的最小AC数大于第二组中的最大AC数. 问共有多少种不同的选择方案. 思路: 简单数学.. ...

  3. 洛谷试炼场-简单数学问题-P1403 [AHOI2005]-因数

    洛谷试炼场-简单数学问题 P1403 [AHOI2005]约数研究 Description 科学家们在Samuel星球上的探险得到了丰富的能源储备,这使得空间站中大型计算机"Samuel I ...

  4. 洛谷试炼场-简单数学问题-P1045 麦森数-高精度快速幂

    洛谷试炼场-简单数学问题 B--P1045 麦森数 Description 形如2^P−1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果PP是个素数,2^P-1 不一定也是素数.到19 ...

  5. 洛谷试炼场-简单数学问题-P1088 火星人

    洛谷试炼场-简单数学问题 A--P1088 火星人 Description 人类终于登上了火星的土地并且见到了神秘的火星人.人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法 ...

  6. HDU 1564 简单博弈 水

    n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个 ...

  7. 简单数学算法demo和窗口跳转,关闭,弹框

     简单数学算法demo和窗口跳转,关闭,弹框demo <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&quo ...

  8. HDU 1840 Equations (简单数学 + 水题)(Java版)

    Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...

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

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

  10. HDU 2050 【dp】【简单数学】

    题意: 中文. 思路: 不难发现数学规律是这样的,每次增加的划分区域的数量是每次增加的交点的数量再加一.然后就总结出了递推公式. #include<stdio.h> ]; int main ...

随机推荐

  1. Ubuntu Builder —— 一个制作自己的发行版的工具

    Ubuntu Builder 是一个使用起来很简单的用来构建基于 Ubunut 的自己的发行版的工具. 你可以下载最新的 Ubuntu Builder 的 DEB 安装包.下载和安装请前往:http: ...

  2. [Raobin] Ext.net在多重子父窗体中找到当前窗体的父窗体,并关闭IFrame父窗体

    var closeParentWindow = function () { var currentWin = window; while (top != currentWin) { var prent ...

  3. LoadRunner 录制IE 8卡死

    LoadRunner11录制脚本,对IE的版本是有所限制的,它只是支持IE 8 以下版本,其中包括IE 8,高出IE 8版本Loadrunner是不支持的. 我遇到LoadRunner录制脚本时IE8 ...

  4. Spark0.8.0的安装配置

    1.profile export SCALA_HOME=/home/hadoop/scala-2.9.3SPARK_080=/home/hadoop/spark-0.8.0export SPARK_H ...

  5. deep learning(1)BP神经网络原理与练习

    具体原理参考如下讲义: 1.神经网络 2.反向传导 3.梯度检验与高级优化 看完材料1和2就可以梳理清楚bp神经网络的基本工作原理,下面通过一个C语言实现的程序来练习这个算法 //Backpropag ...

  6. 算法导论学习-heapsort

    heap的定义:如果数组a[1,....n]满足:a[i]>a[2*i] && a[i]>a[2*i+1],1<=i<=n/2,那么就是一个heap,而且是ma ...

  7. PHP函数积累总结(Math函数、字符串函数、数组函数)

    Math函数:10个较常用标红.abs — 绝对值acos — 反余弦acosh — 反双曲余弦asin — 反正弦asinh — 反双曲正弦atan2 — 两个参数的反正切atan — 反正切ata ...

  8. [MySQL]快速解决"is marked as crashed and should be repaired"故障

    具体报错如下: Table '.\Tablename\posts' is marked as crashed and should be repaired 提示说论坛的帖子表posts被标记有问题,需 ...

  9. MariaDB-5.5.33a 编译安装

    交代一下内核的信息 [root@localhost soft]# uname -r 2.6.32-71.el6.x86_64 创建mariadb用户组 [root@localhost mariadb- ...

  10. Ⅴ.spring的点点滴滴--引用其他对象或类型的成员

    承接上文 引用其他对象或类型的成员 .net篇(环境为vs2012+Spring.Core.dll v1.31) public class Person { public string Name { ...