Maximum Splitting Codeforces Solution

Maximum Splitting Codeforces Solution

In this post, the Maximum Splitting Codeforces Solution is given. Question details : Technocup 2018 - Elimination Round 2, problem (C) Maximum splitting.

Maximum Splitting Codeforces Solution

#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[100005];
bool isprime(ll x )
{
if(x==1)
{
return 0 ;
}
for(int i = 2 ; i*i <= x ; i++)
{
if(x%i==0)
{
return 0;
}
}
return 1 ;
}
int main()
{
int t ; cin >> t ;
while(t--)
{
ll x ;
cin >> x ;
if( x <= 5 and x!=4 || x==7 || x==11)
{
cout << -1 << endl;
}
else if(x%4==0)
{
cout << x /4 << endl;
}
else if(x%4==1 )
{
cout << (x-9)/4 + 1 << endl;
}
else if(x%4==2)
{
cout << (x-6)/4 + 1 << endl;
}
else if(x%4==3 )
{
ll ans = 1 ;
ll z = (x-9);
ans++;
cout << (z-6)/4 + ans << endl;
}
}
}

Maximum Splitting Codeforces Solution by Vishal Vaibhab (IIT BHU). If you like TheCode11, then do follow us on Facebook, Twitter and Instagram.

Previous Post Next Post

Contact Form