結果

問題 No.575 n! / m / m / m...
ユーザー kotatsugamekotatsugame
提出日時 2017-10-09 21:46:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 77,064 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-10 21:19:52
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,388 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 12 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:20:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   20 | main()
      | ^~~~

ソースコード

diff #

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