HDU 1060 求N^N的最高位 (数学,科学计数法+log10()函数)
2015-12-14 21:21
246 查看
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
Sample Output
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.
#include<iostream> #include<cstring> #include<cstdio> #include<cstring> #include<cmath> using namespace std; typedef long long ll; int main() { ll n,ans; long double t; int _; cin>>_; while(_--) { cin>>n; t=n*log10(n); t=t-(ll)t; ans=pow(10,t); cout<<ans<<endl; } return 0; }
相关文章推荐
- 搜索二维矩阵——LintCode
- Beta版本冲刺———第六天
- Python: range()与xrange()区别
- java集合——集合接口+迭代器接口
- 管道
- nginx源码解读之二--nginx_string_t
- Zookeeper-Zookeeper可以干什么
- 不同APP通过SharedPreferences传递数据(共享数据)
- 黑马程序员之JAVA CUI
- ASP.NET内核几大对象、ASP.NET核心知识(6)--转载
- 局部内部类为什么只能访问final局部变量?
- leetcode -- Rotate Image -- 要看有trick
- hive基本操作
- linux 备份策略
- LeetCode Longest Palindromic Substring
- CCF 201312-4 有趣的数(数位DP)
- CDH5.5上安装Rhadoop,RStudio server版初始化SparkR
- 【bzoj 4347】 [POI2016]Nim z utrudnieniem - 博弈论 DP
- 迭代法解题课后
- 文章标题