Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerEarth Divisible problem solution

YASH PAL, 31 July 2024
In this HackerEarth Split houses problem solution, you are given an array A of size N that contains integers. Here, N is an even number. You are required to perform the following operations:
  1. Divide the array of numbers in two equal halves
  2. Note: Here, two equal parts of a test case are created by dividing the array into two equal parts.
  3. Take the first digit of the numbers that are available in the first half of the array (first 50% of the test case)
  4. Take the last digit of the numbers that are available in the second half of the array (second 50% of the test case)
  5. Generate a number by using the digits that have been selected in the above steps
Your task is to determine whether the newly-generated number is divisible by 11.
hackerEarth Divisible problem solution

HackerEarth Divisible problem solution.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << 'n'
int main(int argc, char const *argv[]) {

return 0;
}

second solution

#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vll vector<ll>
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin>>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define fulll(v) v.begin(),v.end()
#define vecin(n, v) for(ll i=0; i<n;i++) cin>>v[i];
#define vecout(n, v) for(ll i=0; i<n;i++) cout<<v[i]<<" "; cout<<endl;
#define rep(i, s, n) for(ll i=(ll)s;i<(ll)n;i++)
#define rrep(i, s, n) for(ll i=(ll)s;i>=(ll)n;i--)
#define pb push_back
#define mkp make_pair
#define endl "n"
#define test cout<<"test line"<<endl;
#define swapper void swap(ll *a, ll *b){ll t=*a;*a=*b;*b=t;}
#define pll pair<ll,ll>
#define vpll vector<pll >
#define mod 1000000007
#define INF 0x3f3f3f3f
#define MAX 100005

using namespace std;

int main(){

llin(n);
assert(n>=1 && n<=100000);
ll se=0, so=0;
rep(i,0,n){
string s;
cin>>s;
stringstream check(s);
ll val;
check>>val;
assert(val>=1 && val<=100000);
if(i<n/2)
i&1?so+=s[0]-'0':se+=s[0]-'0';
else
i&1?so+=s.back()-'0':se+=s.back()-'0';
}
if(se==so)
cout<<"OUI";
else
cout<<"NON";
return 0;
}

coding problems

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes