Last active
September 29, 2017 15:53
-
-
Save dharm6619/1c9578b9fbefaa598af34f9b44003e01 to your computer and use it in GitHub Desktop.
September Circuits Problem 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
cin>>n; | |
vector<int>height; | |
int num; | |
while(n--) | |
{ | |
cin>>num; | |
height.push_back(num); | |
} | |
int q,qry,a=height.size(); | |
int count = 0; | |
cin>>q; | |
while(q--) | |
{ | |
cin>>qry; | |
for(int j=0;j<a;j++) | |
{ | |
if(height[j]%qry==0) | |
{ | |
count = count + 1; | |
} | |
} | |
cout<<count<<endl; | |
count=0; | |
qry=0; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Optimize this code to reduce the time complexity