結果

問題 No.575 n! / m / m / m...
ユーザー ryoissyryoissy
提出日時 2017-10-07 15:07:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 149,204 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 19:29:03
合計ジャッジ時間 2,649 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 12 ms
4,384 KB
testcase_25 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,m;
vector<ll> vec;
vector<int> cnts;

int main(void){
	scanf("%lld%lld",&n,&m);
	ll mp=m;
	for(ll i=2;i*i<=n;i++){
		if(mp%i==0LL){
			vec.push_back(i);
			cnts.push_back(0);
			while(mp%i==0LL){
				cnts[cnts.size()-1]++;
				mp/=i;
			}
		}
	}
	if(mp!=1LL){
		vec.push_back(mp);
		cnts.push_back(1);
	}
	ll cnt=0;
	ll np=n;
	int pp=1;
	for(int i=0;i<vec.size();i++){
		ll now=vec[i];
		ll tmp=0;
		while(1){
			tmp+=n/now;
			if(n/now<vec[i])break;
			now*=vec[i];
		}
		tmp/=(ll)cnts[i];
		if(i==0)cnt=tmp;
		else cnt=min(cnt,tmp);
	}
	long double sum=lgammal(n+1LL);
	sum/=log(10);
	long double nex=log10l(m);
	sum-=(long double)nex*cnt;
	ll resp=sum;
	double rest=(long double)sum-resp;
	printf("%.5fe%lld\n",pow(10,rest),resp);
	return 0;
}
0