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 ...
随机推荐
- chrome插件 postman插件 接口测试、API & HTTP 请求调试工具
Postman 是一个非常棒的Chrome扩展,提供功能强大的API & HTTP 请求调试. 它能够发送任何类型的HTTP requests (GET, HEAD, POST, PUT..) ...
- dubbo spring2.5.6与spring 3冲突解决
dubbo的详细资料请参考: http://alibaba.github.io/dubbo-doc-static/Administrator+Guide-zh.htm#AdministratorGui ...
- QQ输入法个人设置
常用 按键 外观 词库 账户 高级
- WPF——绑定数据库数据(Listview)
一.首先先画一个窗体,放进一个Listview 然后给每列起好名字,并且绑定的数据是临时表的列名 二.造一个临时表用来存储数据,并且将扔进去的Listview绑定到这个临时表DataTable上面 p ...
- A标签执行JS脚本
A标签执行JS脚本 分类: Web2012-12-25 22:48 1368人阅读 评论(0) 收藏 举报 前言 A标签是html中常用的标签,它与button按钮是实现页面跳转的两种最常用的方式,经 ...
- RAC SCAN
在介绍SCAN之前, 先简单的回顾一下ORACLE 关于IP 地址的命名用, 在9I RAC时, ORACLE没有自己的CLUSTERWARE, 主要依靠第三方的集群软件(如HACMP等), 客户端主 ...
- 彻底解决:请求被中止: 未能创建 SSL/TLS 安全通道
最近有个项目要调用客户用java写的带https的webservice,对方提供了证书文件 test.pfx,我这里调用方式如下: //webservice代理类 SvcService svc = n ...
- Alexander Grothendieck去世了
Alexander Grothendieck (German: [ˈɡroːtn̩diːk]; French: [ɡʁɔtɛndik]; 28 March 1928 – 13 November 201 ...
- 提升WI-FI信号强度的10大方法
原文链接:http://server.51cto.com/Net-402889.htm
- C#学习:集合、迭代、泛型(1)
一.System.Collections名称空间下几个接口表征着集合的功能: 1.IEnumerable:表征着迭代功能 public interface IEnumerable { IEnumera ...