uva 10791 和最小的LCM
2017-07-26 15:48
323 查看
#include<cstdio> #include<cstring> #include<cmath> using namespace std; int main() { long long n; int t=1; while(~scanf("%lld",&n)&&n) { long long x=n,res=0,len=(long long)sqrt(n); int cnt=0; for(long long i=2;i<=len&&x>1;i++) { if(x%i==0) { cnt++; long long int t=1; while(x%i==0&&x>1) { t*=i; x/=i; } res+=t; } } if(x>1) { res+=x; cnt++; } if(cnt<2) printf("Case %d: %lld\n",t++,n+1); else printf("Case %d: %lld\n",t++,res); } }
相关文章推荐
- uva 10791 (gcd,lcm,最小和表示法,单个质因子总和得凑起来)
- 例题10-4 UVA 10791 Minimum Sum LCM (最小公倍数的最小和)
- UVa 10791 和最小的LCM (质因数分解)
- LCM的最小和(uva 10791)
- uva 10791 Minimum Sum LCM(拆分素因子)
- Minimum Sum LCM 唯一分解定理+求质因数UVA - 10791
- Minimum Sum LCM(UVA 10791)
- Minimum Sum LCM UVA - 10791
- Minimum Sum LCM UVA - 10791 思维题
- UVA 10791 Minimum Sum LCM(唯一分解定理)
- [UVa 10791]Minimum Sum LCM
- Minimum Sum LCM 唯一分解定理+求质因数UVA - 10791
- uva 10791 Minimum Sum LCM ( 唯一分解定理 )
- UVa 10791 - Minimum Sum LCM 质因数分解加素数筛优化
- Uva 10791 - Minimum Sum LCM 解题报告(因式分解)
- UVA 10791 Minimum Sum LCM
- UVA 10791 Minimum Sum LCM
- UVa 10791 Minimum Sum LCM (数论&素因子分解)
- Minimum Sum LCM 唯一分解定理+求质因数UVA - 10791
- UVa 10791 - Minimum Sum LCM 质因数分解加素数筛优化