結果
| 問題 |
No.575 n! / m / m / m...
|
| コンテスト | |
| ユーザー |
Lepton_s
|
| 提出日時 | 2017-10-29 16:35:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,860 bytes |
| コンパイル時間 | 688 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 05:19:13 |
| 合計ジャッジ時間 | 2,124 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#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 100
Num fact[N];
const Num E = exp(1);
Num logf(ll x){
return x<N ? log10(fact[x]) : log10(2*PI*x)*0.5 + (log10(x)-log10(E))*x;
}
ll calc2(ll x, ll y){
ll cnt = 0;
while(x){
x /= y;
cnt += x;
}
return cnt;
}
ll calc(ll x, ll y){
ll res = x;
for(ll i = 2; i < 1e6; i++){
if(y%i==0){
ll r = 0;
while(y%i==0){
y /= i;
r++;
}
chmin(res, calc2(x, i)/r);
}
}
if(y>1) chmin(res, calc2(x, y));
return res;
}
int main(){
fact[0] = 1;
rep(i, N-1) fact[i+1] = fact[i]*(i+1);
ll x, y;
cin>>x>>y;
ll cnt = calc(x, y);
cout.precision(5);
Num res = logf(x);
res -= log10(y)*cnt;
ll d = floor(res);
res -= d;
cout<<fixed<<pow(10, res)<<'e'<<d<<endl;
return 0;
}
Lepton_s