[NLP] European education hair sugar

Source: Internet
Author: User
[Problem description] After ou taught Lele to send a lollipop, the fans in the data center are not balanced. As a result, ou Jiao had to buy a lot of sugar to send it to fans. But the new problem arises: every friend wants more sugar, so the principle of average allocation won't work here. As a result, ou Jiao found a set of difficult questions on the Internet and produced a lot of data. The test scores were used as the criteria for sending sugar. Of course, the European education sugar standard is also very strange: For keyou A, if the score of T in other friends is a score factor, then t sugar is sent to. Now, Ouyang Jiao has determined the score of each friend. He wants to know how much sugar each friend can get. [Input data] the first line is an integer N, indicating a total of N friends in the data center. Next there are n rows in total. Each row has an integer, Bi, which indicates the I-th individual's score. Output Data: N rows in total. Row I indicates the sugar count obtained by the person I. [Sample input] 222 [sample output] 11 [data range and Conventions] 1 ≤ n ≤ 100000; 1 ≤ Bi ≤ 1000000.

This topic describes the application of the attention method.
Use a CNT array to record the number of approx. s of each node, and then use the embedding method, each time we use the current number to screen all the data larger than it (of course, the number of screened data must be a multiple of this number), we can eliminate ourselves in the final output.

In addition, the sorting of all numbers can be faster (put all the same numbers together for screening ).
Accode:

# Include <cstdio> # include <cstdlib> # include <algorithm> # include <string> const int maxn = 100010, maxp = 1000010; int CNT [maxp], A [maxn], C [maxn], n, Lim; inline int getint () {int res = 0; char TMP; while (! Isdigit (TMP = getchar (); Do res = (RES <3) + (RES <1) + TMP-'0 '; while (isdigit (TMP = getchar (); Return res;} int main () {freopen ("candy. in "," r ", stdin); freopen (" candy. out "," W ", stdout); n = getint (); For (INT I = 0; I <n; ++ I) Lim = STD: max (Lim, A [I] = C [I] = getint (); STD: Sort (C, C + n); For (INT I = 0; I <N; ++ I) {int tot = 1; while (C [I] = C [I + 1]) ++ tot, ++ CNT [C [I ++]; ++ CNT [C [I]; for (int tmp = C [I] <1; TMP <Lim + 1; TMP + = C [I]) CNT [TMP] + = tot;} For (INT I = 0; I <n; ++ I) printf ("% d \ n", CNT [A [I]-1); Return 0 ;}

Related Article

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.