hdu 3816 To Be NUMBER ONE
来源:互联网 发布:湖北广电网络营业厅 编辑:程序博客网 时间:2024/06/05 10:48
这是一道典型的数学题,只要套公式即可。
1/n=1/(n+1)+1/(1+n)*(n)
2分解成3和6,3分解成4和12,4分解成5和20。。。。注意每次从最小的分解。
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 6 Accepted Submission(s) : 4
Special Judge
Font: Times New Roman | Verdana | Georgia
Font Size:← →
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
代码:
#include<iostream>using namespace std;int f[400];int main(){ int i,j,flag; memset(f,0,sizeof(f)); f[2]=1; f[3]=1; f[6]=1; printf("2 3 6\n"); i=4; while(i<=18) { i++; for(j=2;j<=i*i;j++) { if(f[j]&&!f[j+1]&&!f[(j+1)*j]) { f[j]=0; f[j+1]=1; f[(j+1)*j]=1; break; } } flag=1; for(j=2;j<=(i+1)*(i+1);j++) { if(f[j]) { if(flag){ printf("%d",j);flag=0;} else printf(" %d",j); } } printf("%\n"); } //system("pause"); return 0;}
- hdu 3816 To Be NUMBER ONE
- HDU 3816 To Be NUMBER ONE
- 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...
- hdu 1081 to be max
- 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()
- HDU 3031 To Be Or Not To Be
- HDU 3031 To Be Or Not To Be(左偏树)
- 什么才叫精通C++
- 关于DLL工程中存在全局变量可能导致MFC内存泄露误报的原因分析及解决办法
- 黑马程序员--Java入门基础(二)
- hibernate抓取策略
- 今天我进组啦——行业计价产品线
- hdu 3816 To Be NUMBER ONE
- 一个游戏程序员的学习资料
- obj格式文件导入到opengl中 OBJLoader
- 工具方法 删除路径文件夹
- WSAEWOULDBLOCK错误
- jquery日历的开发和实现代码
- java中的别名机制
- Android高配置手机为何没iOS流畅
- I2C