Ural 1118. Nontrivial Numbers 求因子和
来源:互联网 发布:virtualbox装centos 编辑:程序博客网 时间:2024/06/06 00:48
1118. Nontrivial Numbers
Time limit: 2.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Specialists of SKB Kontur have developed a unique cryptographic algorithm for needs of information protection while transmitting data over the Internet. The main advantage of the algorithm is that you needn't use big numbers as keys; you may easily do with natural numbers not exceeding a million. However, in order to strengthen endurance of the cryptographic system it is recommended to use special numbers - those that psychologically seem least "natural". We introduce a notion oftriviality in order to define and emphasize those numbers.
Triviality of a natural number N is the ratio of the sum of all its proper divisors to the number itself. Thus, for example, triviality of the natural number 10 is equal to 0.8 = (1 + 2 + 5) / 10 and triviality of the number 20 is equal to 1.1 = (1 + 2 + 4 + 5 + 10) / 20. Recall that a proper divisor of a natural number is the divisor that is strictly less than the number.
Thus, it is recommended to use as nontrivial numbers as possible in the cryptographic protection system of SKB Kontur. You are to write a program that will find the less trivial number in a given range.
Input
The only line contains two integers I and J, 1 ≤ I ≤ J ≤ 106, separated with a space.
Output
Output the only integer N satisfying the following conditions:
- I ≤ N ≤ J;
- N is the least trivial number among the ones that obey the first condition.
Sample
24 28
25
Problem Author: Leonid Volkov
Problem Source: USU Open Collegiate Programming Contest October'2001 Junior Session
Problem Source: USU Open Collegiate Programming Contest October'2001 Junior Session
#include <iostream>#include <cstdio>using namespace std;int main(){ double ans = 10000000, res, m; int t, i, j,l, r; bool flag; while(cin>>l>>r) { flag=true; if(l == 1) { printf("1\n"); continue; } if(l == r) { printf("%d\n", l); continue; } for(i = r; i >= l; i --) { res = 0; for(j = 2; j*j <= i; j ++) { if(i%j == 0) { m = i/j; res += m+j; if(m == j) res -= m; } } res /= i*1.0; if(res < ans) { ans = res; t = i; } if(res == 0) { flag=false; printf("%d\n", i); break; } } if(flag) printf("%d\n", t); } return 0;}
- Ural 1118. Nontrivial Numbers 求因子和
- Timus 1118. Nontrivial Numbers
- Ural1118-Nontrivial Numbers
- hdu1215 求因子和
- Ural 1049. Brave Balloonists 求因子的个数
- 质数及求因子和
- 求2014^X 因子和
- Smith Numbers 素数打表+暴力+求素因子+poj
- 求因子
- poj1845求n的因子和
- ZOJ 2095 Divisor Summation (求因子和)
- 求n的因子的个数和。.
- 求因子数的和问题
- 1104: 求因子和(函数专题)
- OJ1104: 求因子和(函数专题)
- Problem 21 Amicable numbers (分解因子和)
- ural 1002 Phone numbers
- ural 1002 phone numbers
- 毕向东_JavaScript视频_HTML
- ERROR: 9-patch image xxxx.9.p malformed. Frame pixels must be either solid or transparent
- Java中Runnable和Thread的区别
- C语言不可不用的关键字
- ListView的监听器中OnItemClick各个参数的作用
- Ural 1118. Nontrivial Numbers 求因子和
- MyEclipse非常方便的快捷键
- PERL 中引用
- C# 网络编程之网页简单下载实现
- Balsamiq Mockups——非常不错的原型设计软件
- 给文件及文件夹设置密码
- Junit使用教程(二)
- WPF异步载入图片,附带载入中动画
- vim中如何复制