We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 151e26f commit c0db551Copy full SHA for c0db551
38_codechef_fits_square_in_triangle.cpp
@@ -0,0 +1,37 @@
1
+//
2
+// main.cpp
3
+// CODECHEF
4
5
+// Created by Prince Kumar on 14/05/19.
6
+// Copyright © 2019 Prince Kumar. All rights reserved.
7
+// --- ** Fits square in the triangle ** ---
8
+
9
+#include <iostream>
10
+using namespace std;
11
+int main()
12
+{
13
+ int T; cin>>T;
14
+ while(T--)
15
+ {
16
+ int b; cin>>b;
17
+ if(b==1 || b==2 ||b==3)
18
+ cout<<"0"<<endl;
19
+ else
20
21
+ if(b%2==0) // for EVEN
22
23
+ int area = 0.5 * b *b;
24
+ int res = (area - b )/4;
25
+ cout<<res<<endl;
26
+ }
27
+ else // for ODD
28
29
+ b=b-1;
30
31
32
33
34
35
36
37
+}
0 commit comments