-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem 9.cpp
65 lines (51 loc) · 1.33 KB
/
problem 9.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007
#define for1(k,n) for(ll i=k;i<n;i++)
#define for2(k,n) for(ll j=k;j<n;j++)
#define E cout<<endl
#define max 100000
#define matrix vector <vector <ll>>
int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(0);
//////////////////////////////////////start...............
// finding pythagorian triplet where a2 + b2 =c2 and a+b+c=1000
int flag = 0;
for (int i = 1; i < 1001; i++)
{
for (int j = 1; j < 1001; j++)
{
for (int k = 1 ; k < 1001; k++)
{
;
if (i + j + k == 1000 && (i * i) + (j * j) == (k * k) )
{
flag = 1;
cout << i << " " << j << " " << k << endl;
cout << i*j*k << endl;
break;
}
}
if (flag == 1)
break;
}
if (flag == 1)
break;
}
/////////////////////////////end................................... ....
#ifndef ONLINE_JUDGE
//printf("\nRun Time -> %.10fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
return 0;
}
//c v a s selecting text or x for selecting cut
//ctrl+d after selecting text to select same type
//ctrl+shift+d for copy and paste the line below it
//ctrl+del to delete a text
//ctrl+left to jump left of line or vice versa
//ctrl+shift+"/" to comment whole block and vice versa for undo
//ctrl+"/" for commenting a line