Thursday, 6 April 2017

Geeksforgeeks Solution For " Arithmetic Number "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Arithmetic Number 

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
#include<math.h>
using namespace std;

int main() {
int t,a,b,c;
cin>>t;
while(t--)
{
   cin>>a>>b>>c;
   if(c==0)
   {
       if(a==b)
          cout<<"1";
       else
         cout<<"0";
   }
   else
   {
       if((b>a && c<0) || (b<a && c>0))
       {
           cout<<"0"<<endl;
           continue;
       }
       int d=(b-a);
       if(a==b || d%c==0)
          cout<<"1";
       else
          cout<<"0";
   }
   cout<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Arithmetic Number  "

No comments:
Write comments

Recommended Posts × +