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. Delphi Dll 消息处理

    转载:http://blog.csdn.net/lailai186/article/details/8770643 事情的导火线是GIF图片的显示. 在应用程序中, 利用三方的GIFImage.pas ...

  2. Codeforces 566 D. Restructuring Company

    Description 一开始有 \(n\) 个元素,可以进行几个操作. 合并 \(x,y\) . 合并 \(x,x+1,...,y\) . 询问 \(x,y\) 是否在一个集合中. Sol 并查集+ ...

  3. python对象的生命周期

    引言 碰到以下问题: 代码1: from Tkinter import * root = Tk() photo = PhotoImage(file=r'E:\workspace\python\111. ...

  4. sublime配置markdown

    1.安装sublime 2.安装package control 3.ctrl+shift+P输入install进入Install Packages 4.安装markdown preview 5.配置删 ...

  5. 页面加载时执行JQ代码

    $(function () { //jq加载时执行的这里面是 $("#ss").append("<strong>这是新加的</strong>&qu ...

  6. kendoUI grid 过滤时出错:TypeError toLowerCase is not a function

    错误原因:类型不一致. 有些过滤类型为字符串,有些为整型时.

  7. Unity3d 换装Avatar系统

    原理就是用新造的部件和角色的骨骼进行重新对接. demo的使用方法: PartIdx设置要换那个部件[0,4],一共5个部件 EquipIdx设置要更换部件的装备索引[0,1],具体看我的Change ...

  8. [Linux]centOS7-1-1503-x86_64下安装VM-TOOLS

    1.安装Perl. 2.如果提示 The path "" is not a valid path to the 3.10.0-229.el7.x86_64 kernel heade ...

  9. win7,ubuntu双系统——重装win7后如何恢复ubuntu引导

    磁盘分区——windows 7自带分区工具实现 磁盘分区——PQ硬盘分区魔术师 win7,ubuntu双系统的安装——正式安装 win7,ubuntu双系统的安装——卸载ubuntu 讲述了我的  w ...

  10. css 自动换行 [英文、数字、中文]

    white-space:normal;overflow: auto;table-layout:fixed; word-break: break-all;