程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> hdu 3816 To Be NUMBER ONE 一道數論 主要是思路

hdu 3816 To Be NUMBER ONE 一道數論 主要是思路

編輯:C++入門知識

To Be NUMBER ONE
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 383    Accepted Submission(s): 190
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.
 

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.
 

Sample Output
2 3 6
2 4 6 12
 
題意
分別用3到18個數 的倒數相加 等於1  
並且每個數要求 小於等於 個數+1的平方
比如 用3個數
那麼要找3個數滿足 這三個數小於等於(3+1)*(3+1) 且倒數之和為1
 
思路:
一個倒數可以分解問2個數的倒數之和
1/n= 1/(a*b)=1/a*(a+b) + 1/b*(a+b)
 
故 在已知 上層的情況下 可以直接將上一層的數分解為2個數  以此類推即可
 
手算  我沒有寫程序
[cpp] 
#include<stdio.h> 
int main() 

     
                printf("2 3 6\n"); 
                printf("2 4 6 12\n"); 
                printf("2 5 6 12 20\n"); 
                printf("2 5 7 12 20 42\n"); 
                printf("3 5 6 7 12 20 42\n"); 
                printf("3 5 6 8 12 20 42 56\n"); 
                printf("3 5 6 8 16 20 42 48 56\n"); 
                printf("3 5 6 12 16 20 24 42 48 56\n"); 
                printf("3 5 6 16 20 21 24 28 42 48 56\n"); 
                printf("3 5 6 16 21 24 28 36 42 45 48 56\n"); 
                printf("3 5 6 16 24 28 30 36 42 45 48 56 70\n"); 
                printf("3 5 6 16 28 30 33 36 42 45 48 56 70 88\n"); 
                printf("3 5 6 16 28 33 36 39 42 45 48 56 70 88 130\n"); 
                printf("3 5 6 16 33 36 39 42 44 45 48 56 70 77 88 130\n"); 
                printf("3 5 6 20 33 36 39 42 44 45 48 56 70 77 80 88 130\n"); 
                printf("3 5 6 24 33 36 39 42 44 45 48 56 70 77 80 88 120 130\n"); 
                 
                return 0; 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved