紫上给得比较奇怪,其实没有必要用唯一分解定理。我觉得这道题用唯一分解只是为了表示大数。

但是分解得到的幂,累乘的时候如果顺序很奇怪也可能溢出。其实直接边乘边除就好了。因为答案保证不会溢出,

设定一个精度范围,如果中间结果超过了精度范围就保存起来,最后sort一遍从两端同时乘就不会溢出了。

/*********************************************************
* --------------Tyrannosaurus--------- *
* author AbyssalFish *
**********************************************************/
/*
数的表示,唯一表示,固定进制,变进制(编码),素因子幂
不唯一表示 很多
*/
#include<bits/stdc++.h>
using namespace std; const int maxn = 1e4+; vector<double> ans_fac;
const double up_b = 1e8, low_b = 1e-; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int p, q, r, s;
while(~scanf("%d%d%d%d", &p, &q, &r, &s)){
int m = max(p, r), x = p-q, y = r-s;
double ans = ;
for(int i = ; i <= m; i++){
int t = ;
if(q < i && i <= p) t++;
if(i <= x) t--;
if(s < i && i <= r) t--;
if(i <= y) t++;
if(t){
if(t < )
while(ans /= i, ++t) ;
else
do ans *= i; while( --t) ;
if(ans > up_b || ans < low_b) {
ans_fac.push_back(ans);
ans = ;
}
}
}
if(ans_fac.size()){
sort(ans_fac.begin(),ans_fac.end());
int i = , j = ans_fac.size()-;
while(i < j){
ans *= ans_fac[i++]*ans_fac[j--];
}
if(i == j) ans *= ans_fac[i];
ans_fac.clear();
}
printf("%.5lf\n", ans);
}
return ;
}

最新文章

  1. Java程序员必须掌握的8大排序算法
  2. Dubbo消费端错误: ClassNotFoundException: org.apache.zookeeper.proto.WatcherEvent
  3. 难道只有我一个人想吐槽npm这种包管理方式么
  4. mybatis.net insert 返回主键
  5. UIButton详解
  6. POJ 3114 Countries in War(强连通)(缩点)(最短路)
  7. 框架使用的技术主要是SpringMVC 在此基础上进行扩展
  8. c#局域网文件搬移
  9. 传送门(portal)
  10. cocos2d-x 2.2.3 之菜单分析(1)
  11. 自定义 select 下拉菜单
  12. hdu 3056 病毒侵袭持续中 AC自己主动机
  13. 如何解决Android SDK无法下载Package的问题(.net)
  14. 我的iOS-App
  15. Eclipse错误:Implicit super constructor ClassName is undefined for default constructor. Must define an explicit constructor
  16. Hadoop(十一)Hadoop IO之序列化与比较功能实现详解
  17. 第八章:Python基础の面向对象(二)
  18. 2017广东工业大学程序设竞赛E题(倒水)
  19. LANMP系列教程之Apache编译安装CentOS7环境
  20. python 学习三

热门文章

  1. C++的STL总结(1)
  2. 将图片至于jsp页面上(层)
  3. 分层图最短路【bzoj2834】: 回家的路
  4. Jmeter_Beanshell_使用Java处理JSON块(转)
  5. Java中keytool管理证书
  6. springMvc配置 中文api
  7. matlab 常用函数(数学建模-复习)
  8. SpringBoot | 第七章:过滤器、监听器、拦截器
  9. 性能测试学习第四天_Loadrunner概述
  10. 从客户端(content1=&quot;&lt;img src=&quot;/web/news/...&quot;)中检测到有潜在危险的 Request.Form 值。