Setter: Rahul Kumar
Tester: Rahul Kumar
Editorialist: Rahul Kumar
DIFFICULTY:
SIMPLE - CAKEWALK
PROBLEM:
Given an integer N, the number of chairs. All the chairs should be placed around the square table such that:
- Each of the four sides will have even number of chairs.
- All the four sides have equal number of chairs. Print the number of chairs on each side else -1 if not possible.
EXPLANATION:
Every side should have even number of chair, so minimum chairs each side is 2. Total minimum chair will be 2*4 = 8. So if the number of chair divisible by 8 then the condition fulfills.
TIME COMPLEXITY:
O(1)
SOLUTION:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n;
if(n%8==0)
cout<<n/4<<"\n";
else
cout<<"-1\n";
}
}