合数分解 UVA
来源:互联网 发布:软件测试基础方法 编辑:程序博客网 时间:2024/05/19 17:50
//合数分解+组合数计算 #include<iostream>#include<cstdio>#include<cmath>#include<cstring> using namespace std;typedef unsigned long long ll;const int maxn=1e4+5;int dp[maxn],bp[maxn];int al,bl,cl,dl;bool cp[maxn];void pre(){ dp[0]=0; memset(cp,false,sizeof(cp)); for(int i=2;i<=10000;i++){ if(!cp[i]) dp[++dp[0]]=i; for(int j=i*i;j<=10000;j+=i) cp[j]=true; }}void solve(int a,int b){ for(int i=a;i>=2;i--){ int nl=i; for(int j=1;j<=dp[0];j++){ while(nl%dp[j]==0) nl/=dp[j],bp[j]+=b; if(nl==1)break; } }}void dis(){ for(int i=1;i<=dp[0];i++) cout<<bp[i]<<" "; cout<<endl;}int main(){ pre(); while(cin>>al>>bl>>cl>>dl){ memset(bp,0,sizeof(bp)); solve(al,1); solve(al-bl,-1); solve(bl,-1); solve(cl-dl,1); solve(dl,1); solve(cl,-1); double ans=1; for(int i=1;i<=dp[0];i++) ans*=pow(dp[i],bp[i]); printf("%.5lf\n",ans); } return 0;}
0 0
- 合数分解 UVA
- 合数分解
- [模板]合数分解
- 合数唯一分解定理
- 【数论 / 数值】【RQNOJ】大合数分解
- 【SGU】113. Nearly prime numbers 合数分解
- HDU 5317 RGCDQ (合数分解+预处理)
- hdu 4777 树状数组+合数分解
- LightOJ - 1236 Pairs Forming LCM 合数分解
- Pollard "p-1"方法 分解合数的因素;
- poj1811(素数判断与合数分解模板)
- 把一个合数分解为几个质因数相乘
- LightOJ 1341 - Aladdin and the Flying Carpet【合数分解】
- 质数与合数系列——分解质因数
- UVA 11752 The Super Powers——合数
- UVA 10392 大数分解
- UVa 10392 大数分解
- UVA 10780 (唯一分解)
- 文章标题
- Oracle Study---Oracle 11g 不可见索引案例
- linux中rpm命令的一些使用总结
- 散列函数设计:除留余数法
- 三条技巧让你的译文“说得通”
- 合数分解 UVA
- web.xml version3.1 配置
- pwntools初体验
- flex布局
- POJ 3213 PM3 可能会
- 每天一个adb命令:am 命令详解
- 练习系统 实验一 谁拿了最多的奖学金
- 并规排序求逆序对数 hud 4911
- 传感器