-
Notifications
You must be signed in to change notification settings - Fork 0
/
1272.cpp
55 lines (55 loc) · 940 Bytes
/
1272.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int div(int a,int b)
{
if (a>b)
{
a+=b;
b=a-b;
a-=b;
}
return b/a;
}
int main()
{
bool res[101]={0};
queue<int> q;
vector<int> v;
int n,i,t,j,p;
cin>>n;
for (i=0;i<n;++i)
{
cin>>t;
res[t]=true;
for (j=0;j<v.size();++j)
{
p=div(t,v[j]);
if (!res[p])
{
q.push(p);
res[p]=true;
}
}
v.push_back(t);
}
while (!q.empty())
{
t=q.front();
for (j=0;j<v.size();++j)
{
p=div(t,v[j]);
if (!res[p])
{
q.push(p);
res[p]=true;
}
}
v.push_back(t);
q.pop();
}
int count=0;
for (i=1;i<100;++i) if (res[i]) ++count;
cout<<count;
}