To Be NUMBER ONE + 数论
来源:互联网 发布:信号干扰器软件 编辑:程序博客网 时间:2024/05/16 01:51
To Be NUMBER ONE
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 408 Accepted Submission(s): 207
Special Judge
Problem Description
One is an interesting integer. This is also an interesting problem. You are assigned with a simple task.
Find N (3 <= N <= 18) different positive integers Ai (1 <= i <= N), and
Any possible answer will be accepted.
Find N (3 <= N <= 18) different positive integers Ai (1 <= i <= N), and
Any possible answer will be accepted.
Input
No input file.
Output
Your program’s output should contain 16 lines:
The first line contain 3 integers which are the answer for N = 3, separated by a single blank.
The following 15 lines are the answer for N = 4 to 18, as the same format.
The sample output is the first two lines of a possible output.
The first line contain 3 integers which are the answer for N = 3, separated by a single blank.
The following 15 lines are the answer for N = 4 to 18, as the same format.
The sample output is the first two lines of a possible output.
Sample Output
2 3 62 4 6 12/*思路:一个倒数可以分解问2个数的倒数之和1/n= 1/(a*b)=1/a*(a+b) + 1/b*(a+b)*/#include<iostream>#include<cmath>using namespace std ;int main(void){int a[100] ,cnt = 0 ;a[0] = 2 ;a[1] = 3 ;a[2] = 6 ;int k = 3 ;while(cnt < 16){int i ;for( i = 0 ; i < cnt + 2 ; i ++)cout<<a[i]<<" ";cout<<a[cnt+2]<<endl;int j ,flag = 0 ;for( i = 0 ; i < cnt + 3 ; i ++){for( j = 2 ; j <= a[i] ; j ++){if(a[i] % j == 0 ){int b , c , d , tag = 0 , tag1 = 0 ;d = a[i] / j ;b = j*( j + d) ;c = d * ( j + d ) ;if(!(b<=(k+1)*(k+1) && c <=(k+1)*(k+1)))continue ;for(int l = 0 ; l < k ; l++)if(a[l] == b){tag = 1;break;}for( l = 0 ; l < k ; l ++)if(a[l] == j){tag1 = 1;break;}if(tag == 0 || tag == 0){a[i] = b ;a[k ++] =c ;flag = 1;break;}}}if(flag)break;}cnt ++ ;}return 0;}
- To Be NUMBER ONE + 数论
- hdu 3816 To Be NUMBER ONE 一道数论 主要是思路
- hdu 3816 To Be NUMBER ONE
- HDU 3816 To Be NUMBER ONE
- [math] hdu 3816 to be no. one
- To be the better one for programing
- In order to be irreplaceable, one must always be different.
- 1024.Palindromic Number (25)...to be continued...
- number one
- number one
- Number one
- number one
- One Chance To Be The God Of Chrysanthemum
- one method to resolve table cell can not be selected
- Expected one result (or null) to be returned by selectOne()
- function to count the number of "1" of one byte
- what should you be as a programmer?To be the last one and become experienced!
- input text have to be number or character
- HTML5之Javascript多线程
- float后导致IE6中左右的border消失-解决方案
- Codeforces Round #166 (Div. 1) && (Div. 2)
- liferay-ui message 给错误信息传递参数
- Sharepoint 2010 BDC 之 访问已被业务数据连接拒绝
- To Be NUMBER ONE + 数论
- dbutils
- hdu 2123 An easy problem
- GUIskin的一些体会
- 第9次实验任务
- 从源代码编译OGRE和编写测试程序
- 在执行一次后, 就sleep(10);会不会不让程序超时
- 程序员的奋斗史(二十)——沉思录(一)——关于博客和思想
- GIT 用 MELD比较文件