Factorial vs Power

题意

输入a,找到满足n!>a^n 最小的n。

数据

第一行T(1 <= T <= 1e5),表示测试样例数.(2 <= a <= 1e6)。

输入

3

2

3

4

输出

4

7

9

这个东西一看就知道是二分求解的,但是我们还是不知道怎么求的,我们可以吧他们取对数然后我们很惊奇的发现原来真的是取对数啊,

最后原来的式子就变成了这个样子。。。

[ln(1)+ln(2)+ln(3)+....+ln(n)]>n*lna

然后因为ln(n)为正数所以我们就把ln(n)除过去,大不了我们n=1的时候特判一下啊。。。然后我们求一下导数,然后发现导数我不会求啊,所以我们只能两个式子相减然后发现这个东西真的是单调递增的啊。。。‘

时间: 2024-08-23 11:10:34

Factorial vs Power的相关文章

Spoj-FACVSPOW Factorial vs Power

Consider two integer sequences f(n) = n! and g(n) = an, where n is a positive integer. For any integer a > 1 the second sequence is greater than the first for a finite number of values. But starting from some integer k, f(n) is greater than g(n) for

check a int number is power of 2?

个人信息:就读于燕大本科软件工程专业 目前大三; 本人博客:google搜索"cqs_2012"即可; 个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献; 博客内容:how many does the factorial of n have zero? 博客时间:2014-5-7; 编程语言:Java ; 编程坏境:Windows 7 专业版 x64; 编程工具:jdk,eclipse x64; 制图工具:office 2010 ppt; 硬件信息:7G-3 笔记

LightOJ 1035 Intelligent Factorial Factorization

题目: Description Given an integer N, you have to prime factorize N! (factorial N). Input Input starts with an integer T (≤ 125), denoting the number of test cases. Each case contains an integer N (2 ≤ N ≤ 100). Output For each case, print the case num

2016.5.16——leetcode:Rotate Array,Factorial Trailing Zeroe

Rotate Array 本题目收获: 题目: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. 思路: 我的思路:新建一个数组存放旋转后的内容,但是怎么把原数组的内容存放在数组中,不清楚. leetcode/discuss思路: 思路一:新建数组,复制原

[LeetCode] Factorial Trailing Zeros

Well, to compute the number of trailing zeros, we need to first think clear about what will generate a trailing 0? Obviously, a number multiplied by 10 will have a trailing 0 added to it. So we only need to find out how many 10's will appear in the e

MOOCULUS微积分-2: 数列与级数学习笔记 6. Power series

此课程(MOOCULUS-2 "Sequences and Series")由Ohio State University于2014年在Coursera平台讲授. PDF格式教材下载 Sequences and Series 本系列学习笔记PDF下载(Academia.edu) MOOCULUS-2 Solution Summary Let $(a_n)$ be a sequence of real numbers starting with $a_0$. Then the power

[LeetCode] Power of Three

Given an integer, write a function to determine if it is a power of three. Follow up:Could you do it without using any loop / recursion? 判断一个数是否是3的幂,则这个数a的所有的约数都是3的幂,如果一个数b小于这个数a且是3的幂,则这个数b一定是a的约数.所以找出3的最大的幂,然后用这个数对n取余即可. class Solution { public: boo

poj 3134 Power Calculus(迭代加深dfs+强剪枝)

Description Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications: x2 = x × x, x3 = x2 × x, x4 = x3 × x, …, x31 = x30 × x. The operation of squaring can be appreciably shorten the sequence of multiplications.

POJ 3233 - Matrix Power Series ( 矩阵快速幂 + 二分)

POJ 3233 - Matrix Power Series ( 矩阵快速幂 + 二分) #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; #define MAX_SIZE 30 #define CLR( a, b ) memset( a, b, sizeof(a) ) int MOD = 0; int n, k; st