Leftmost Digit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12229    Accepted Submission(s): 4674

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060

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.

 
Author
Ignatius.L
 
Recommend
We have carefully selected several similar problems for you:  1018 1061 1573 1066 1005 
代码:
 #include<iostream>
#include<cmath>
using namespace std;
int main()
{
int sum;
while(cin>>sum)
{
while(sum--)
{
double n;
scanf("%lf",&n);
double x=n*log10(n*1.0);
_int64 y=(_int64)x;
double xy=x-y;
int temp=(int)pow(10.0,xy);
printf("%d\n",temp);
}
}
return ;
}
 

【hdu 1060】【求N^N最低位数字】的更多相关文章

  1. HDU 5230 ZCC loves hacking 大数字的整数划分

    http://acm.hdu.edu.cn/showproblem.php?pid=5230 把题目简化后,就是求 1---n - 1这些数字中,将其进行整数划分,其中整数划分中不能有重复的数字,如果 ...

  2. shelll函数求两个输入数字之和

    #!/bin/bash #This is a test of the addition of the program! function AddFun { read -p "Enter a ...

  3. 面试题:m个长度为n的ordered array,求top k 个 数字

    package com.sinaWeibo.interview; import java.util.Comparator; import java.util.Iterator; import java ...

  4. 【C语言】输入一组整数,求出这组数字子序列和中最大值

    //输入一组整数.求出这组数字子序列和中最大值 #include <stdio.h> int MAxSum(int arr[],int len) { int maxsum = 0; int ...

  5. 用java求一个整数各位数字之和

    /* * 用java求一个整数各位数字之和 */ public class Test02 { public static void main(String[] args) { System.out.p ...

  6. HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用)

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

  7. HDU 1060 Leftmost Digit【log10/求N^N的最高位数字是多少】

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

  8. 区间求小于等于k的数字个数 hdu4177

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4417 题目意思给出一个序列,叫我们求一个区间里面小于等于k的数字个数. 这里面我用分块和主席树两种方法 ...

  9. 题解报告:hdu 1060 Leftmost Digit

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1060 问题描述 给定一个正整数N,你应该输出N ^ N的最左边的数字. 输入 输入包含多个测试用例. ...

随机推荐

  1. 如何预览github中的html页面

    在github里面的文件路径是https://github.com/gavin125/Sass-test/blob/master/html/index.html 那么我们需要在这个地址前面加上http ...

  2. HDU 1712 裸分组dp

    http://acm.hdu.edu.cn/showproblem.php?pid=1712 N门课M天复习,第i门课花费j天获得的效益是dp[i][j] 求最大效益 分组背包,同一门课不能选两次 三 ...

  3. 5.1---二进制数插入(CC150)

    public class Solution { public static int binInsert(int n, int m, int i, int j) { // write code here ...

  4. 1个简单的Log

    #pragma once #include <windows.h> #include <process.h> class CLogger { public: static CR ...

  5. Bitnami --https://bitnami.com/stacks

    Bitnami is an app store for server software. Install your favorite applications in your own servers ...

  6. poj 1789

    http://poj.org/problem?id=1789 这是一道图论的题,个人觉得和那个POJ1258是差不多的,就是多了一步,题目难以读懂 题目的意思:就是给你一群字符串要你找字符串对应的字符 ...

  7. Java集合中Map接口的使用方法

    Map接口 Map提供了一种映射关系,其中的元素是以键值对(key-value)的形式存储的,能够实现根据key快速查找value: Map中的键值对以Entry类型的对象实例形式存在: 建(key值 ...

  8. Unity3d 用NGUI制作做新手引导的思路

    一.先看下效果 Prefab结构 二.实现思路: 1.prefab上的Panel层级设置成较高 2.背景由5个UISprite拼接起来的,4个(L,R,U,D)当作遮罩,1个镂空(Hollow)当作点 ...

  9. C#操作字符串方法总结<转>

    staticvoid Main(string[] args) { string s =""; //(1)字符访问(下标访问s[i]) s ="ABCD"; Co ...

  10. FastReport报表对象介绍一:“Text”对象

    FastReport中文网 http://www.fastreportcn.com/Article/70.html ------------------------------------------ ...