Bzoj 1607 patting Heads Pat Bull Head

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.