結果
| 問題 | No.575 n! / m / m / m... | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-10-07 15:07:15 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 13 ms / 2,000 ms | 
| コード長 | 870 bytes | 
| コンパイル時間 | 1,301 ms | 
| コンパイル使用メモリ | 163,064 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-17 04:27:11 | 
| 合計ジャッジ時間 | 2,400 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%lld%lld",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
            
            ソースコード
#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;
}
            
            
            
        