結果

問題 No.575 n! / m / m / m...
ユーザー kotatsugame
提出日時 2017-10-09 21:24:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 760 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 77,876 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-11-17 07:04:38
合計ジャッジ時間 41,356 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 2 TLE * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
long n,m,c,d;
double N,M;
double mypow(double a,long b)
{
	if(b==0)return 1;
	else
	{
		while(a>=10)d+=b,a/=10;
		a=mypow(a*a,b/2)*(b%2?a:1);
		while(a>=10)d++,a/=10;
		return a;
	}
}
main()
{
	cin>>n>>m;N=n,M=m;
	for(long i=2;i*i<=m;i++)
	{
		if(m%i==0)
		{
			long cnt=0,a=n/i;
			while(m%i==0)m/=i,cnt++;
			for(long j=i;~-n/j+1>=j;a+=n/j)j*=j;
			c=max(c,a/cnt);
		}
	}
	if(m>1)
	{
		long a=n/m;
		for(long j=m;~-n/j+1>=j;a+=n/j)j*=j;
		c=max(c,a);
	}
	N++;
	double ori=(N+1/(12*N-1/(10*N)))/M_E;
	double f=sqrtl(2*M_PI/N)*mypow(ori,N);
	for(long i=0;i<c;i++)f/=M;
	while(f>=10)d++,f/=10;
	while(f<1)d--,f*=10;
	cout<<fixed<<setprecision(15)<<f<<"e"<<d<<endl;
}
0