HDU 1060 Leftmost Digit(数论)
来源:互联网 发布:js压缩 tomcat 编辑:程序博客网 时间:2024/06/06 03:02
Description
给出一整数n,输出n^n的最高位
Input
第一行为用例组数T,每组用例占一行为一整数n
Output
对于每组用例,输出n^n的最高位
Sample Input
2
3
4
Sample Output
2
2
Solution
这道题直接算肯定不行,也不能用快速幂之类的算法,所以只能找公式了,显然n可以表示成此形式,我们要求的即为x
同时我们有,
不妨令
那么则
Code
#include<cstdio>#include<iostream>#include<cmath>using namespace std;int main(){ int t; cin>>t; while(t--) { double n; cin>>n; double temp=n*(log(n)/log(10.0))-floor(n*(log(n)/log(10.0))); int ans=(int)(pow(10.0,temp)); cout<<ans<<endl; } return 0;}
0 0
- HDU 1060 Leftmost Digit (数论)
- HDU 1060 Leftmost Digit(数论)
- HDU 1060 Leftmost Digit(数论)
- Leftmost Digit(数论)
- Leftmost Digit(数论)
- Leftmost Digit (HDU 1060)
- Leftmost Digit(HDU 1060)
- HDU 1060 Leftmost Digit & BIT1046 Leftmost Digit
- hdoj 1060 Leftmost Digit 【数论】
- Leftmost Digit(对数,数论)
- HDU1060:Leftmost Digit(数论)
- hdu 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- HDU 1060 LeftMost Digit
- HDU 1060 Leftmost Digit
- 1047 -- 排序
- 在android studio中,使用getAssets获取文件的问题
- 黑马程序员——Java之多态性
- 《程序员思维训练》读书小记
- android开发SQLite之getReadableDatabase() 和 getWritableDatabase()方法
- HDU 1060 Leftmost Digit(数论)
- 1048 -- 求某一整数序列的全排列问题
- nusoap传递对象数组
- Web请求过程
- 字符串_模式匹配算法(求子串)
- 1049 -- 矩阵翻转
- Leetcode: Reverse Linked List
- 1050 -- C语言合法标识符
- 第一天