Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Alternative Square Pattern Problem Code: SQALPAT
Add problem to Todo list

You're given a number N. Print the first N lines of the below-given pattern.

1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
30 29 28 27 26
Input:
First-line will contain the number N.
Output:
Print the first N lines of the given pattern.

Constraints
1≤N≤200
Sample Input 1:
4
Sample Output 1:
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
Sample Input 2:
2
Sample Output 2:
1 2 3 4 5
10 9 8 7 6
EXPLANATION:
In the first example, we'll print the first 4 lines of the given pattern.
In the second example, we'll print the first 2 lines of the given pattern.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
using namespace std;

int main() {
int n;
cin>>n;
int sumi = 0, sumj = 10;
for(int i=1; i<=n; i++){
if(i%2!=0){
for(int j=sumi+1; j<=sumi+5; j++){
cout<<j<<" ";
}
cout<<endl;
sumi = sumi + 10;
}else{
for(int j=sumj; j>=sumj-4; j--){
cout<<j<<" ";
}
cout<<endl;
sumj = sumj + 10;
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Sum Is Everywhere Problem Code: SUMEVOD
Add problem to Todo list

You are given a number N and find the sum of the first N odd and even numbers in a line separated by space. All even and odd numbers should be greater than 0.

Input:
First-line will contain the number N.
Output:
Print the sum of the first N odd and even numbers in a line separated by space.

Constraints
1≤N≤106
Sample Input 1:
4
Sample Output 1:
16 20
Sample Input 2:
1
Sample Output 2:
1 2
EXPLANATION:
In the first example, (1 + 3 + 5 + 7) = 16 and (2 + 4 + 6 + 8) = 20.
In the second example, only one odd that is 1 and only one even that is 2.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#define ll long long
using namespace std;

int main() {
// your code goes here
ll n,even,odd;

cin>>n;
even = n(n+1);
odd = nn;
cout<<odd<<" "<<even;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Triangle Everywhere Problem Code: EXTRICHK
Add problem to Todo list

You're given the length of three sides a, b, and c respectively. Now If these three sides can form an Equilateral Triangle then print 1, if these three sides can form an Isosceles Triangle then print 2, if these three sides can form a Scalene Triangle then print 3, otherwise print −1.

Input:
First-line will contain three numbers a, b, and c separated by space.
Output:
Print the answer in a new line.

Constraints
1≤a,b,c≤103
Sample Input 1:
2 4 3
Sample Output 1:
3
Sample Input 2:
4 4 4
Sample Output 2:
1
Sample Input 3:
4 4 9
Sample Output 3:
-1
EXPLANATION:
In the first example, (2, 4, 3) will form a Scalene Triangle.
In the second example, (4, 4, 4) will form an Equilateral Triangle.
In the third example, (4, 4, 9) will not form a triangle.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;

int main()
{
int a, b, c;
cin >> a >> b >> c;
if (a + b > c && b + c > a && c + a > b)
{
if (a == b && b == c)
cout << "1";
else if (a == b b == c c == a)
cout << "2";
else
cout << "3";
}
else
cout << "-1";
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Triangle With Angle Problem Code: ANGTRICH
Add problem to Todo list

You're given the three angles a, b, and c respectively. Now check if these three angles can form a valid triangle with an area greater than 0 or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).

Input:
First-line will contain three numbers a, b, and c separated by space.
Output:
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).

Constraints
0≤a,b,c≤180
Sample Input 1:
20 40 120
Sample Output 1:
YES
Sample Input 2:
100 18 42
Sample Output 2:
NO
EXPLANATION:
In the first example, angles set (20, 40, 120) can form a triangle with an area greater than 0.
In the second example, angles set (100, 18, 42) will never form a valid triangle.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
using namespace std;

int main() {

int a,b,c;
cin>>a>>b>>c;
if(a+b+c==180&& a>0 && b>0 && c>0){
cout<<"YES";
}
else{
cout<<"NO";
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
You're given the length of three sides a, b, and c respectively. Now check if these three sides can form a triangle or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).

Input:
First-line will contain three numbers a, b, and c separated by space.
Output:
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).

Constraints
1≤a,b,c≤106
Sample Input 1:
2 4 3
Sample Output 1:
YES
Sample Input 2:
1 1 4
Sample Output 2:
NO
EXPLANATION:
In the first example, (2, 4, 3) can form a triangle with an area greater than 0.
In the second example, (1, 1, 4) will never form a valid triangle.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
using namespace std;

int main()
{
int a, b, c;
cin >> a >> b >> c;
if (a + b < c a + c < b b + c < a)
cout << "NO";
else
cout << "YES";
return 0;
}