2015
04-13

# To Be NUMBER ONE

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.

No input file.

No input file.

2 3 6
2 4 6 12

/**
[math] hdu 3816 to be no. one

1/n= 1/(a*b)=1/a*(a+b) + 1/b*(a+b)

*/
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;
int f[19][19] = {{},{},{},{0,2,3,6}};
void cal(int k,int &a,int &x,int &y)
{
int i,j,b,m;
for(i = 2; i < k; ++i)
{
m =sqrt(f[k][i] * 1.0);
for(a = 1; a <= m; ++ a)
if(f[k][i] % a == 0)
{
b = f[k][i] / a;
if(a == b)
continue;
x = (a + b) * a;
y = (a + b) * b;
if(x > k * k || y > k * k)
continue;
for(j = 1; j <= k && f[k][j] != x && f[k][j] != y; ++j);
if(j == k + 1){
a = i;
return ;
}
}
}
}
int main(){
int x = 0,y = 0,p = 0,i,j;
for(i = 4; i <= 18; ++i){
for(j = 1; j < i; ++j)
f[i][j] = f[i-1][j];
cal(i,p,x,y);
f[i][p] = x;
f[i][j] = y;
}
double res;
for(i = 3;i < 19;++i){
sort(f[i]+1,f[i] + 1 + i);
res = 0.0;
for(j = 1;j < i; ++j)
printf("%d ",f[i][j]);
printf("%d\n",f[i][j]);
}
return 0;
}


1. 题本身没错，但是HDOJ放题目的时候，前面有个题目解释了什么是XXX定律。
这里直接放了这个题目，肯定没几个人明白是干啥