亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 10991 | 回復(fù): 2
打印 上一主題 下一主題

[其他] Project Euler - 009 [復(fù)制鏈接]

論壇徽章:
4
白羊座
日期:2013-11-05 10:26:09冥斗士
日期:2015-11-17 14:19:55白銀圣斗士
日期:2015-11-17 15:13:0815-16賽季CBA聯(lián)賽之新疆
日期:2016-04-01 09:10:58
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2015-09-28 10:18 |只看該作者 |倒序?yàn)g覽
本帖最后由 icymirror 于 2015-09-28 10:23 編輯

Problem 009:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product a,b,c.

問題9:
畢達(dá)哥拉斯數(shù)(勾股數(shù))是三個自然數(shù),他們有關(guān)系:a*a + b*b = c*c
例如:3*3 + 4*4 = 25 = 5*5
在1000內(nèi)有一組畢達(dá)哥拉斯數(shù),并且滿足:a + b + c = 1000。
試找出這三個數(shù)的乘積。

代碼:

  1. package main

  2. import (
  3.         "fmt"
  4. )

  5. func Problem009(scope int) int {
  6.         var result int
  7.         for edgec := scope / 3 + 1; edgec < scope / 2; edgec++ {
  8.                 for edgeb := 1; edgeb < edgec; edgeb++ {
  9.                         edgea := scope - edgec - edgeb
  10.                         if (edgea < edgeb && edgeb < edgec) {
  11.                                 if (edgea * edgea + edgeb * edgeb == edgec * edgec) {
  12.                                         result =edgea * edgeb * edgec
  13.                                 }
  14.                         }
  15.                 }
  16.         }
  17.        
  18.         return result
  19. }

  20. func main() {
  21.         fmt.Println("Problem 009 result: ", Problem009(1000))
  22. }
復(fù)制代碼

論壇徽章:
6
數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2015-11-27 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-01 06:20:00每日論壇發(fā)貼之星
日期:2015-12-01 06:20:0015-16賽季CBA聯(lián)賽之佛山
日期:2017-03-26 23:38:0315-16賽季CBA聯(lián)賽之江蘇
日期:2017-07-17 10:08:4415-16賽季CBA聯(lián)賽之北京
日期:2018-03-04 17:01:50
2 [報(bào)告]
發(fā)表于 2017-03-01 10:20 |只看該作者
Collison預(yù)言Go語言將在兩年內(nèi)稱霸云領(lǐng)域

  1. package main

  2. import "fmt"
  3. var puts = fmt.Println

  4. func P009(end int) {
  5.         for c := end / 2; c > 1; c-- {
  6.                 c2 := c * c
  7.                 ab := end - c
  8.                 for b := c - 1; b > ab/2; b-- {
  9.                         if a := ab - b; a*a+b*b == c2 {
  10.                                 puts(a, b, c, "=", a*b*c)
  11.                                 return
  12.                         }
  13.                 }
  14.         }
  15. }

  16. func main() {
  17.         P009(1000)
  18. }
復(fù)制代碼

論壇徽章:
6
數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2015-11-27 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-01 06:20:00每日論壇發(fā)貼之星
日期:2015-12-01 06:20:0015-16賽季CBA聯(lián)賽之佛山
日期:2017-03-26 23:38:0315-16賽季CBA聯(lián)賽之江蘇
日期:2017-07-17 10:08:4415-16賽季CBA聯(lián)賽之北京
日期:2018-03-04 17:01:50
3 [報(bào)告]
發(fā)表于 2017-03-01 10:22 |只看該作者
200 375 425 = 31875000
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP