結果

問題 No.575 n! / m / m / m...
ユーザー kotatsugamekotatsugame
提出日時 2017-10-09 21:24:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 760 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 77,876 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-28 14:26:43
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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