hdu1060 Leftmost Digit
2015-08-17 16:59
232 查看
题目(http://acm.hdu.edu.cn/showproblem.php?pid=1060)
求n^n最右侧的数,设m=n^n,两边取对数m=10^(n*log10(n)),由于10的正整数次方都和个位没关系,只与小数部分有关。
求n^n最右侧的数,设m=n^n,两边取对数m=10^(n*log10(n)),由于10的正整数次方都和个位没关系,只与小数部分有关。
#include <iostream> #include <math.h> using namespace std; int main() {int t; cin>>t; while(t--) { int n; cin>>n; double tmp=n*log10(double(n)); double power=tmp-floor(tmp); int ans=pow(10.0,power); cout<<ans<<endl; } return 0; }
相关文章推荐
- Java多线程-线程的同步与锁
- Python自动发布Image service的实现
- Python自动发布Image service的实现
- 用一张图片制作skybox图片 (如何制作360全景图、立方体)
- Sublime Text3 安装和简单实用
- Posix 信号量
- [置顶] 一个经典的消费者和生产者的实现(linux )
- 写一个dup2功能相同的函数,不能调用 fcntl 函数,并且要有出错处理
- PAT 1041. Be Unique (20)
- CSUOJ1404集合的并
- 分布式文件系统FastDFS架构剖析
- 写一个dup2功能相同的函数,不能调用 fcntl 函数,并且要有出错处理
- MySQL命令行备份还原数据库
- 欢迎使用CSDN-markdown编辑器
- django 如何使用django自带的user做外键
- PHP调优
- 解决微信扫码下载的两个方法
- Win10系统下怎么给电脑设置双屏显示?
- C++ map的基本操作和使用
- Java常用23种设计模式详解