Ultraviolet A 340-master-mind hints

Source: Internet
Author: User

The English description of this question is too redundant. Finally, after reading the question described in one sentence, I understood http://blog.163.com/kakarrot@yeah/blog/static/12011592520106241155854 /. In fact, it is to count the number of identical numbers in the same columns of two sequences and the number of identical numbers in different columns. Note that any element in the two columns cannot be reused if it has already been used.

Since there are only nine numbers, you only need to count the number of each number. First, calculate the statistics of the same numbers in the same column, that is, the number corresponding to the same number in the same column is reduced by one. Then count the number of nine numbers that appear in the two sequences. Each number is added with a smaller value that appears in the other two sequences. ViewCodeIt's easy.

# Include <stdio. h> # include <string. h> # include <stdlib. h> # define min (A, B) (a) <(B )? (A): (B) int main () {int s [1005], G [1005], n; int A [15], B [15], c [15]; int COUNT = 1; while (scanf ("% d", & N) {memset (C, 0, sizeof (c )); for (INT I = 0; I <n; I ++) {scanf ("% d", & S [I]); c [s [I] ++;} printf ("game % d: \ n", Count ++); While (1) {memcpy (a, c, sizeof (c); // assign the number of 1-9 counts in the Code to the array memset (B, 0, sizeof (B )); for (INT I = 0; I <n; I ++) {scanf ("% d", & G [I]); B [G [I] ++;} If (0 = G [0]) break; int x = 0, y = 0; For (INT I = 0; I <n; I ++) if (s [I] = G [I]) {A [s [I] --; B [s [I] --; X ++;} For (INT I = 1; I <= 9; I ++) Y + = min (A [I], B [I]); printf ("(% d, % d) \ n", x, y) ;}} return 0 ;}

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.