博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1060 Leftmost Digit【log10/求N^N的最高位数字是多少】
阅读量:6949 次
发布时间:2019-06-27

本文共 1200 字,大约阅读时间需要 4 分钟。

Leftmost Digit

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

Total Submission(s): 19010    Accepted Submission(s): 7507

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
【分析】:
【代码】:
#include 
using namespace std;typedef long long LL;const int MOD = 7;typedef vector
vec;typedef vector
mat;int main(){ int n,t,ans; double tmp; cin>>t; while(t--){ cin>>n; tmp=n*log10(1.0*n); tmp=tmp-(__int64)tmp; ans=(int)(pow(10.0,tmp)); printf("%d\n",ans); } return 0;}
数论

 

转载于:https://www.cnblogs.com/Roni-i/p/8351572.html

你可能感兴趣的文章
管理团队时,怎样保证一直做正确的事?
查看>>
如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。...
查看>>
表单元素之搭车系
查看>>
mysql+redis
查看>>
[Android]Dagger2Metrics - 测量DI图表初始化的性能(翻译)
查看>>
sublime开启vim模式
查看>>
Rikka with Chess(规律)
查看>>
【设计模式】迭代器模式
查看>>
MATLAB中imshow()和image()
查看>>
Atitit.eclipse git使用
查看>>
JAVA逆向&反混淆-追查Burpsuite的破解原理(转)
查看>>
cocos2dx 3.1从零学习(一)——入门篇(一天学会打飞机)
查看>>
文档批量格式化之word技能
查看>>
C#~异步编程再续~await与async引起的w3wp.exe崩溃
查看>>
c3p0数据库连接池死锁问题
查看>>
SVN版本冲突解决
查看>>
java多线程知识点汇总(四)多线程知识点脉络图
查看>>
nginx的upstream目前支持5种方式的分配
查看>>
android图像处理(3) 底片效果
查看>>
stl 之set图解
查看>>