To Be NUMBER ONE
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.
2 4 6 12
对分母进行分解:
n可以分解成 1/n = 1/(n+1) + 1/(n+1)*n
例如 从2 3 6 开始
不能有相同的 所以只能从 2分解成 3 6 前面已经含有了,然后只能从3开始改,每次从最小的开始分解。
下一项变成 2 4 6 12
下一项不能分解 2因为会多出来6 所以应当选择 2 5 6 12 20
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{int a[400],i,j,flag;
memset(a,0,sizeof(a));
a[2]=1;
a[3]=1;
a[6]=1;
printf("2 3 6\n");
i=4;
while(i<=18)
{i++;
for(j=2;j<i*i;j++)
{
if(a[j]&&!a[j+1]&&!a[(j+1)*j])
{
a[j]=0;
a[j+1]=1;
a[(j+1)*j]=1;
break;
}
}
flag=1;
for(j=2;j<(i+1)*(i+1);j++)
{
if(a[j])
{
if(flag)
{
printf("%d",j);
flag=0;
}
else
printf(" %d",j);
}
}
printf("\n");
}
return 0;
}
To Be NUMBER ONE的更多相关文章
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
- Harmonic Number(调和级数+欧拉常数)
题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- 移除HTML5 input在type="number"时的上下小箭头
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...
- iOS---The maximum number of apps for free development profiles has been reached.
真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...
- [LeetCode] Number of Boomerangs 回旋镖的数量
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...
- [LeetCode] Number of Segments in a String 字符串中的分段数量
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...
随机推荐
- 转:为什么Eclipse中 按 F3 无效
通常是由于自己的 工程 建得不对, 没有声明为 JAVA 或 PHP 类型工程. 例如, PHP 工程的 .project 文件中的内容如果如下, F3 应该就可以起作用了. <?xml ver ...
- 【HDOJ】4400 Mines
(1) KD树,但实际没有STL快,3000+ /* 4400 */ #include <iostream> #include <string> #include <ma ...
- tlplayer,wzplayer所有平台通用加密测试视频
此视频文件为通用版本,支持tlplayer,wzplayer,能在ios,android,windows,mac等平台上使用,发布此文件紧为方便用户测试. 下载地址:http://www.coolra ...
- WCF - Overview
WCF stands for Windows Communication Foundation. The elementary feature of WCF is interoperability. ...
- ccleaner的专业版和商业版的注册码
名称:Registered User 密钥:CBB4-FJN4-EPC6-G5P6-QT4C 断网注册
- SharePoint 2010在win7 x64 安装
转:http://kaneboy.blog.51cto.com/1308893/328000 关于<SharePoint 2010应用程序开发指南>,我和杜伟同学正在撰写中,希望下半年早点 ...
- Android 应用中十大常见 UX 错误
[核心提示] Android 开发者关系团队每天都会试用无数的 App 或者受到无数的开发者发来的请求评测的 App,在评测如此之多的应用之后,他们总结出了10个最常见的错误. 作为一个长期使用 An ...
- VS2010+WINDBG+VMWARE9.0和fatal error RC1106: invalid option: -ologo错误
提供属性配置文件一份: http://pan.baidu.com/s/1iS1Ix <?xml version="1.0" encoding="utf-8" ...
- nyoj 找球号三(除了一个数个数为基数,其他为偶数,编程之美上的)
#include<iostream> #include<stdio.h> using namespace std; int main() { int len; while(ci ...
- POJ 1458 Common Subsequence 最长公共子序列 LCS
LCS #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> ...