codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

757B.md (1841B)


      1 Source: https://codeforces.com/problemset/problem/757/B
      2 
      3 B. Bash's Big Day
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.
     22 
     23 But Zulu warns him that a group of *k* > 1 Pokemon with strengths {*s*1, *s*2, *s*3, ..., *s**k*} tend to fight among each other if *gcd*(*s*1, *s*2, *s*3, ..., *s**k*) = 1 (see notes for *gcd* definition).
     24 
     25 Bash, being smart, does not want his Pokemon to fight among each other. However, he also wants to maximize the number of Pokemon he takes from the lab. Can you help Bash find out the maximum number of Pokemon he can take?
     26 
     27 Note: A Pokemon cannot fight with itself.
     28 
     29 Input
     30 
     31 The input consists of two lines.
     32 
     33 The first line contains an integer *n* (1 ≤ *n* ≤ 105), the number of Pokemon in the lab.
     34 
     35 The next line contains *n* space separated integers, where the *i*-th of them denotes *s**i* (1 ≤ *s**i* ≤ 105), the strength of the *i*-th Pokemon.
     36 
     37 Output
     38 
     39 Print single integer — the maximum number of Pokemons Bash can take.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3  
     47 2 3 4
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 2
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 5  
     60 2 3 4 6 7
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 3
     67 ```
     68 
     69 Note
     70 
     71 *gcd* (greatest common divisor) of positive integers set {*a*1, *a*2, ..., *a**n*} is the maximum positive integer that divides all the integers {*a*1, *a*2, ..., *a**n*}.
     72 
     73 In the first sample, we can take Pokemons with strengths {2, 4} since *gcd*(2, 4) = 2.
     74 
     75 In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there is no larger group with *gcd* ≠ 1.