好吧这题很水...可是我没想到正解... 题意:求n!有多少位. 正解:斯特林公式. 直接放代码... #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cctype> #include<cstdlib> #include<vector> #include<m…
Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number contain all digit 7 or only 1 digit other than 7. For example, 777 is a happy number because 777 contail all digit 7, 7177 and 87777 both happy number…
Problem Description For non-negative integers x and y, f(x, y) , )=,f(, )=, f(, )=. Now given sets of non-negative integers A and B, for each integer b in B, you should find an integer a in A such that f(a, b) is minimized. If there are more than one…
Description 给你两个整数N和K,要求你输出N!的K进制的位数. Input 有多组输入数据,每组输入数据各一行,每行两个数——N,K Output 每行一个数为输出结果 Sample Input 2 52 1010 10100 200 Sample Output 11769对于100%的数据,有2≤N≤2^31, 2≤K≤200,数据组数T≤200. 题解 用Stirling公式求近似值 位数=logk(n!)+1 ≍ logk(sqrt(2πn)*(n/e)^n)+1 = logk…
题目大意 求N!有多少位 题解 用公式直接秒杀... 代码: #include<iostream> #include<cmath> using namespace std; #define ESP 1e-9 #define Pi acos(-1) #define e exp(1.0) int main() { int T; cin>>T; while(T--) { int digit; double n; cin>>n; digit=(*Pi*n)+n*lo…
Time limit  1000 ms Memory limit   131072 kB Paula and Tai are couple. There are many stories between them. The day Paula left by airplane, Tai send one message to telephone 2200284, then, everything is changing… (The story in “the snow queen”). Afte…
LeetCode 287. Find the Duplicate Number 暴力解法 时间 O(nlog(n)),空间O(n),按题目中Note"只用O(1)的空间",照理是过不了的,但是可能判题并没有卡空间复杂度,所以也能AC. class Solution: # 基本思路为,将第一次出现的数字 def findDuplicate(self, nums: List[int]) -> int: s = set() for i in nums: a = i in s if a…
一只青蛙一次可以跳上1级台阶,也可以跳上2级--它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 其实题目很水...就是一个等比数列通项公式嘛 f(0)=1 f(1)=1 f(n)=f(0)+f(1)+...+f(n-1) ==> f(n)=2*f(n-1) (when n>=2) ==> f(n)=2^(n-1) class Solution { public: int jumpFloorII(int number){ /* 暴力写法 if(number==0){ ret…
Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Solution Substring dp[i][j]表示在节点i结束,字母j最多有多少个,按拓扑排序的顺序计算 Solution Congruence Equation Solution A Game With Numbers 跟SG游戏解决思路差不多 Solution…
题目链接: 传送门 Minimum Inversion Number Time Limit: 1000MS     Memory Limit: 32768 K Description The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbe…