hdu1141
来源:互联网 发布:网页链接打开淘宝app 编辑:程序博客网 时间:2024/06/16 16:26
求最大的n使得满足n!<=2^bit。
bit可以达到256超过long long
然而n!=n*...*1.
两边取对数,就是log(n)+log(n-1)+...+log(1)<=bit
然后暴力求解。
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <algorithm>using namespace std;const double eps=1e-5;const int maxn=1e6+5;int a[25],c[25];double b[maxn];double log(double a,double b){ return log10(a)/log10(b);}int main(){ a[0]=4; for(int i=1;i<21;i++) a[i]=a[i-1]<<1; b[0]=1; int len=0,k=0; for(int i=2;;i++) { b[i]=log(i,2)+b[i-1]; if(b[i]>a[k]) c[k++]=i-1; if(b[i]-a[20]>0) break; len++; } int n; while(scanf("%d",&n),n) { n-=1960; n/=10; printf("%d\n",c[n]); } return 0;}
0 0
- hdu1141
- HDU1141
- hdu1141
- hdu1141
- hdu1141
- hdu1141(数学log)
- HDU1141 Factstone Benchmark(数学)
- hdu1141 (Factstone Benchmark(利用对数进行大数比较))
- Snail—UI学习之UISegmentControl
- hd2141 Can you find it?
- 自动取款机 冲正交易
- 两个字母造成的问题
- android的fragment解析
- hdu1141
- 带你认识 MySQL 之 MySQL 体系结构
- Android 用代码查看本机保存的Wifi密码
- STL之二分查找(binary_search(),lower_bound(),upper_bound() )
- IOS开发之实现App消息推送
- CentOS安装配置JDK环境
- hibernate的缓存机制详解
- GTK进阶学习:鼠标事件
- 【effective c++读书笔记】【第2章】构造/析构/赋值运算(1)