HDU 1060 Leftmost Digit
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12985 Accepted Submission(s): 4973
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).
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.
要了解 log的用法、pow函式的用法
#include<stdio.h>
#include<math.h>
int main()
{
int T,a;
double m;
scanf("%d",&T);
while(T--)
{
__int64 N;
double a;
scanf("%I64d",&N);
m=N*log10((double)N)-(__int64)(N*log10((double)N));
a=pow(10.0,m);
printf("%d\n",(int)a);
}
return 0;
相關文章
- HDU 1060 Leftmost Digit(數論,c++)GitC++
- HDU - 1061 Rightmost Digit(二分快速冪板題)Git
- Nth Digit【難】Git
- Last digit of a huge numberASTGit
- ZOJ First Digit(瞎搞)Git
- LintCode-Digit CountsGit
- GTX1060MQ和GTX1060筆記本顯示卡效能對比:GTX1060MQ對比GTX1060哪個好?MQ筆記
- Nth Digit 第N個數字Git
- LeetCode-Number of Digit OneLeetCodeGit
- 233. Number of Digit OneGit
- UVa 1225 - Digit CountingGit
- Leetcode 400.Nth DigitLeetCodeGit
- Digit Counting uva1225Git
- gtx1060顯示卡怎麼樣什麼水平gtx1060顯示卡可以玩哪些遊戲遊戲
- SG 函式初步 HDU 1536 && HDU 1944函式
- Shape of HDU
- HDU4787
- POJ3187Backward Digit Sums[楊輝三角]Git
- BZOJ4421 : [Cerc2015] Digit DivisionGit
- PAT-B 1060 愛丁頓數【排序】排序
- HDU 2052(C語言+註釋)+HDU 2090C語言
- HDU Find the hotel(RMQ)MQ
- HDU1792(公式)公式
- hdu 2846 Repository
- hdu 1695 GCDGC
- HDU 2051 Bitset
- 簡單的揹包問題(入門)HDU2602 HDU2546 HDU1864
- HDU 3221Brute-force Algorithm(降冪公式 神似hdu4549)Go公式
- GTX1050Ti和GTX1060顯示卡區別對比 GTX1050Ti和GTX1060效能那個好?
- GTX1060 3G與RX480區別對比 GTX1060 3G和RX480哪個好?
- HDU 4858 專案管理專案管理
- HDU 1792 A New Change Problem
- Equivalent Sets(HDU-3836)UI
- Switch Game HDU - 2053GAM
- HDU 4923 Room and MoorOOM
- HDU 2594 (KMP入門)KMP
- HDU 2504 又見GCDGC
- HDU 2043 密碼密碼