Problem Statements
Problem Statements
Problem 1030A
When preparing a tournament, Codeforces coordinators try their best to make the
first problem as easy as possible. This time the coordinator had chosen some
problem and asked n people about their opinions. Each person answered whether
this problem is easy or hard.
If at least one of these n people has answered that the problem is hard, the
coordinator decides to change the problem. For the given responses, check if the
problem is easy enough.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of people who
were asked to give their opinions.
The second line contains n integers, each integer is either 0 or 1. If i-th integer is 0,
then i-th person thinks that the problem is easy; if it is 1, then i-th person thinks
that the problem is hard.
Output
Print one word: "EASY" if the problem is easy according to all responses, or
"HARD" if there is at least one person who thinks the problem is hard.
Input
3
001
Output
HARD
Input
1
0
Output
EASY
Note
In the first example the third person says it is a hard problem, so it should be
replaced.
In the second example the problem easy for the only person, so it doesn't have to
be replaced.
Answer the following questions.
1. Describe your solution approach.
Using for loop to the number of people and checking whether opinion is 1 or
not.
2. What would be your implementation considerations (if any)?
My implementation consideration will be whether anyone feels that the
problem is hard or not simply check for 1 as input , if it is , break the loop
and print hard otherwise print easy
3. Provide your implementation.
#include<stdio.h>
int main()
{
int n,c,flag=0;
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%d",&c);
if(c==1)
{
flag=1;
break;
}
}
if(flag==1)
printf("Hard");
else
printf("Easy");
return 0;
}
Note: Since the problem is simple, the logic can be implemented in the main()
itself.
4. List the test cases.
The test cases used here are:
For(int i=0;i<n;i++)
//Checking no of people
If(i==1)
//Checking if any person feels that the program is difficult or not.
Submission
1. Check out the problem 1030A In Search of an Easy
Problem in https://codeforces.com/problemset/problem/1030/A
2. After checking your solution thoroughly, submit your program and get
an Accepted message.
Problem 2: Integer Sequence Dividing
Problem 1102A
You are given an integer sequence 1,2, …, n . You have to divide it into two sets A and B in
such a way that each element belongs to exactly one set and |sum(A)−sum(B)| is minimum
possible.
The value |x| is the absolute value of x and sum(S) is the sum of elements of the set S.
Input
Output
Print one integer — the minimum possible value of |sum(A)−sum(B)| if you divide the initial
sequence 1,2, …,n into two sets A and B.
Examples
input
3
output
0
input
5
output
1
input
6
output
1
Note
Input
The first line contains a single integer T (1 ≤ T ≤ 1000) — the number of queries.
Each of the next T lines contains two integers L and R (1 ≤ L ≤ R ≤ 998244353) — inclusive
borders of the range.
It is guaranteed that test set only includes queries, which have at least one suitable pair.
Output
Print T lines, each line should contain the answer - two integers x and y such that L≤ x, y ≤
R, x≠y and x divides y. The answer in the i-th line should correspond to the i-th query from
the input.