Title Link: http://www.lydsy.com/JudgeOnline/problem.php?id=1607
Exercises
The title appears to be wrong, and should be "the head of the cow (i.e. excluding itself) that is evenly divisible by the number on the note that is held on the note by the Bull."
There is similar to the idea of a bucket row, with the number of BI records I, with CJ record the results (that is, the number of numbers in a given set of J can be evenly divisible), the next process is similar to the search for a certain range of prime numbers: Every I, I will be all multiples of J cj++, pay attention to minus one when output (remove yourself)
1#include <cstdio>2 intn,a[100010],b[1000010],c[1000010],MAXN;3 intMaxintXinty)4 {5 returnX>y?x:y;6 }7 intMain ()8 {9scanf"%d",&n);Ten for(intI=1; i<=n;i++) One { Ascanf"%d",&a[i]); -b[a[i]]++; -maxn=Max (maxn,a[i]); the } - for(intI=1; i<=maxn;i++) - { - if(B[i]) + { - for(intj=i;j<=maxn;j+=i) + { Ac[j]+=B[i]; at } - } - } - for(intI=1; i<=n;i++) - { -printf"%d\n", c[a[i]]-1); in } - return 0; to}
Bzoj 1607 patting Heads Pat Bull Head