We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
boolcheck(vector<int>b,inti)//special case if a contains only one int{for(unsignedintj=0;j<b.size();j++){if(b[j]%i!=0){//look if current val in a div every int contained in breturnfalse;}}returntrue;}intgetTotalX(vector<int>a,vector<int>b){intcount=0;if(a.size()==1){for(inti=a[0];i<=b[0];i+=a[0]){if(check(b,i))count++;}returncount;}for(unsignedinti=0;i<b.size();i++){// same logic applies hereintcont=0;//dumb way to solve, cont gives information how many divs are doablefor(unsignedintj=0;j<a.size();j++){if(b[i]%a[j]==0){cont++;}}if(cont==a.size()){//cont equals a.size() means current value was successfulcount++;}}returncount;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →