标签:c style class blog code java
题目:
A Pythagorean triplet is a set of three natural numbers, a b c, for which,
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a +
b + c = 1000.
Find the product abc.
代码:
1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 6 for(int i = 1; i < 333; i++){ 7 for(int j = 1; j <= 999; j++) 8 for(int k = 1; k <= 999; k++){ 9 if((i*i + j*j) == (k*k) && (i+j+k) == 1000) 10 cout << i << " " << j << " " << k << endl; 11 } 12 } 13 14 system("pause"); 15 return 0; 16 }
ProjectEuler 009题,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/wanghui390/p/3761822.html