結果

問題 No.575 n! / m / m / m...
ユーザー Lepton_sLepton_s
提出日時 2017-10-29 16:16:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,775 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 85,168 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 22:12:11
合計ジャッジ時間 4,200 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double Num;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 1000
Num fact[N];
const Num E = exp(1);

Num f(ll x){
	return x<N ? fact[x] : sqrt(2*PI*x)*pow(x/E, x);
}

Num logf(ll x){
	return log10(2*PI*x)*0.5 + (log10(x)-log10(E))*x;
}

int main(){
	fact[0] = 1;
	rep(i, N-1) fact[i+1] = fact[i]*(i+1);

	ll x, y;
	cin>>x>>y;
	ll cnt = 0, xx = x;
	while(xx){
		xx /= y;
		cnt += xx;
	}

	cout.precision(4);
	if(x<N){
		Num res = f(x);
		res /= pow(y, cnt);
		ll d = log10(res);
		res /= pow(10, d);
		cout<<fixed<<res<<'e'<<d<<endl;
	} else {
		Num res = logf(x);
		res -= log10(y)*cnt;
		ll d = floor(res);
		res -= d;
		cout<<fixed<<pow(10, res)<<'e'<<d<<endl;
	}
	
	return 0;
}
0