POJ 1423 Big Number
来源:互联网 发布:移动网络玩传奇霸业 编辑:程序博客网 时间:2024/05/22 17:24
这个超时
#include<iostream>#include<math.h>#include<fstream>#include <time.h>using namespace std;#define Len 5500000double s[Len+1];int main(){ s[0]=0; clock_t start = clock(); for(int i=1;i<=Len;++i){ s[i]=log10(i)+s[i-1]; } clock_t endt = clock(); cout<<"t:"<<(double)(endt -start)/CLOCKS_PER_SEC<<endl; //ifstream cin("1.txt"); int t,n; cin>>t; while(t--) { cin>>n; if(n<=Len) cout<<(int)s[n]+1<<endl; else{ double sum=s[Len]; for(int i=Len+1;i<=n;++i){ sum+=log10(i); } cout<<(int)sum+1<<endl; } } return 0;}
这个应用公式
#include <iostream>#include <math.h>#include <fstream>using namespace std;int n;const double e = 2.7182818284590452354, pi = 3.141592653589793239;double f( int a ){ return log10( sqrt( 2 * pi * a ) ) + a * log10( a / e );}int main(){ int cas, ans; double i, s; cin>>cas; while( cas-- ) { cin>>n; if( n < 100000 ) { for( s=0, i=1; i<=n; i++ ) s += log10( i ); } else s = f( n ); ans = (int)s; if( ans <= s ) ans++; cout<<ans<<endl; } return 0;}
0 0
- POJ 1423 Big Number
- POJ 1423 Big Number
- POJ 1423 Big Number
- poj 1423 Big Number
- poj 1423 big number
- POJ 1423 Big Number
- POJ 1423 Big Number
- poj 1423 Big Number
- big number poj 1423
- POJ 1423 Big Number
- POJ 1423 Big Number
- poj - 1423-Big number
- POJ:1423 Big Number
- poj 1423 Big Number
- POJ 1423 Big Number
- 【poj】1423 Big number
- POJ 1423 BIG NUMBER
- POJ 1423 Big Number
- python写的掉空格数字字母的方法
- 输入目录,清除目录下的class文件
- C++多态的灵活运用
- LeetCode 题解(13):Regular Expression Matching
- 0-1背包问题——小P寻宝记
- POJ 1423 Big Number
- 字符串比较——加密术
- 线性表的顺序表示和操作
- SDUT 出现次数
- ZOJ-1057
- 寻找前K大数
- 浏览器与服务器交互信息(序列化与发序列化) ViewState
- c# messagebox弹窗提示及按键信息获取
- weblogic启动内存的设置