Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dharm6619
Last active September 29, 2017 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharm6619/1c9578b9fbefaa598af34f9b44003e01 to your computer and use it in GitHub Desktop.
Save dharm6619/1c9578b9fbefaa598af34f9b44003e01 to your computer and use it in GitHub Desktop.
September Circuits Problem 2
#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;
}
@dharm6619
Copy link
Author

Optimize this code to reduce the time complexity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment