链接:传送门 题意:一个人自命不凡,他从1960年开始每10年更新一次计算机的最长储存长数.1960年为4位,每10年翻一倍.给出一个年份y,问这一年计算机可以执行的n!而不溢出的最大n值 思路:如果直接比较 2^x - 1 < n! 是一定会溢出的,所以不妨对左右取对数,使之变为 x*log10(2) < log10(n!) . 使用斯特林公式优化一下n!的计算就能解决这个问题了. /******************************************************…
对于n位数的计算,我们可以采用(int)log10(n) + 1的方法得到n的位数 第一种方法: 对于n!位数的计算,log10(n!) = log10(1) + log10(2) + ... + log10(n) 为防止直接暴力超时这部分运算可以打表等待主程序调用 #include<iostream> #include<cmath> using namespace std; const int MAXN = 1e7; ]; void action(int m)//打表计算n!位数…
传送门 题意: 给出\(x,x\leq 12\),求最大的\(n\),满足\(n!\leq 2^{2^x}\). 思路: 通过斯特林公式: \[ n!\approx \sqrt{2\pi n}\cdot (\frac{n}{e})^n \] 我们一般可以认为这两个相等= = 将阶乘转化为一个比较好求的式子,然后二分判断一下即可. /* * Author: heyuhhh * Created Time: 2019/12/10 21:14:22 */ #include <iostream> #in…
Big Number Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27027   Accepted: 8626 Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encry…
//题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1.   log2(n!) = log2(1) + log2(2) + .. + log2(n);一个循环即可 2.   Stirling #include <iostream> #include <string> #include<sstream> #include <cmath> #include <map…
/** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = n 枚举即可 拓展: 可以用斯特林(Stirling)公式求解 斯特林(Stirling)公式: log(x) =====ln(x) **/ #include <iostream> #include <cmath> using namespace std; int main() {…
链接:http://poj.org/problem?id=1502 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5249   Accepted: 3237 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed share…
MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4017   Accepted: 2412 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic…
题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor, Jack Swigert, has ask…
POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom /ZOJ 1291 MPI Maelstrom (最短路径) Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shar…