(File IO): input: div.in output: div.out
time limit: 1000 ms space constraints: 131072 KB specific restrictions
Goto ProblemSet
Title Description
Year of the Goat to the village head start learning to teach lamb
language, just learning the four arithmetic operations. The mayor wrote two integers on the board
and
, asked the lamb who have
sheep, equally divided into
sheep village, the village sheep assigned to each number must be the same, the distribution of the maximum number is how much? Lamb were quick to get the answer, each assigned to the village sheep
rats have
sheep can only place orders up. The mayor wrote on the whiteboard
. Yes, this is the
(divisible) usage!
In order to test whether they mastered the lamb divisible operation, the mayor requested lamb took turns selecting any number from two different whiteboard, large numbers divisible by a decimal, if the results are not present on the board, you write the value in on the whiteboard. Integer until the lamb who could not have not seen before.
Although this class is lamb exercise their computing power, but limited classroom time. In order to control classroom time, the mayor wants to know, according to figures on the current whiteboard, eventually there will be a few numbers on the board? Now I ask you to help him write a program to quickly calculate it!
Enter
the first line an integer
, represents an integer number of the current appears on the whiteboard.
second line
integers, separated by spaces, representing the current number on the board, to ensure that each number is different.
Output
output an integer representing the number of the final digital whiteboard.
Sample input
[1] Input Sample
2
16. 3
Sample input [2]
. 3
. 17. 1 2
Sample output
[output 1] Sample
4
[2] Sample Output
5
Data range limit
% of the data,
;
% of the data,
。
Tips
[Sample
explain]
selection
and
, write
; selection
and
, write
; total
, four integers.
Sample 2 [explain]
selection
and
, write down
; then select
and
, write down
; Total
, five integers.
Problem-solving ideas
data is small, you can open a barrel digital memory occurred, it is possible to enumerate violence n ^ 2 x, y derived value, the result once again into the bucket. Because the x / y must be younger than x, it is possible to obtain a result, the final tally all the numbers.
Code
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
int n,a[105],f[105],ans;
int main(){
freopen("div.in","r",stdin);
freopen("div.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
f[a[i]]=1;
}
for(int i=100;i>=1;i--)
{
if(f[i])
{
for(int j=i-1;j>=1;j--)
if(f[j])
f[i/j]=1;
}
}
ans=0;
for(int i=1;i<=100;i++)
if(f[i]==1)
ans++;
printf("%d",ans);
}