(Jizhong) 2181. Frankie divisible (div)

(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 P a s c a l Pascal language, just learning the four arithmetic operations. The mayor wrote two integers on the board 16 16 and 3 3 , asked the lamb who have 16 16 sheep, equally divided into 3 3 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 5 5 rats have 1 1 sheep can only place orders up. The mayor wrote on the whiteboard 5 5 . Yes, this is the D i v Div (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 N N , represents an integer number of the current appears on the whiteboard.
second line N N 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
50 50 % of the data, N < = 50 N<=50
100 100 % of the data, N < = 100 1 < = a i < = 100 N<=100,1<=ai<=100


Tips
[Sample 1 1 explain]
selection 16 16 and 3 3 , write 5 5 ; selection 5 5 and 3 3 , write 1 1 ; total 16 3 5 1 16,3,5,1 , four integers.

Sample 2 [explain]
selection 17 17 and 2 2 , write down 8 8 ; then select 8 8 and 2 2 , write down 4 4 ; Total 17 2 8 4 1 17,2,8,4,1 , 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);
}
Published 119 original articles · won praise 8 · views 4901

Guess you like

Origin blog.csdn.net/kejin2019/article/details/105162432