Sunday, 9 July 2017

Common divisor

#include <iostream>
using namespace std;

int main()
{
   int a,b,c[50],d[50],count=0;
   cin>>a>>b;
   for(int i=0;i<50;i++){
       if(a%(i+1)==0){
           c[i]=i+1;
       }
       
   }
    for(int i=0;i<50;i++){
       if(b%(i+1)==0){
           d[i]=i+1;
       }
       
   }
   for(int i=0;i<50;i++){
       if(c[i]==d[i]){
           cout<<c[i]<<endl;
       
   }}
  
}

No comments:

Post a Comment

Dynamic programming problem

Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix. Please...