HDU 1060 leftmost digit__ winter training

Source: Internet
Author: User
Problem Description Given A positive integer N, you should output the leftmost digit of n^n.
Input the input contains several test cases. The ' the ' 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 "the", 3 * 3 * 3 = leftmost digit is 2. In the second case, 4 * 4 * 4 * 4 = 256, so the leftmost digit is 2. M=n^n, the two sides respectively to the 10 logarithm of the log10 (m) =n*log10 (n), m=10^ (N*LOG10 (n)), since the first of the 10 of any integer power must be 1, so the first of M and N*log10 (n) of the number of parts.
#include <cstdio>
#include <math.h>
int main ()
{
    int t;
	scanf ("%d", &t);
        while (t--)
        {
            unsigned long n;
            scanf ("%lld", &n);
            Double X=n*log10 (n*1.0);
            x-= (__int64) x;
            int A=pow (10.0, x);
            printf ("%d\n", a);
        }
    return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.