Solid foundation --P2550 [AHOI2001] lottery machines

Topic links: https://www.luogu.org/problem/P2550

P2550 [AHOI2001] lottery machines

Title Description

In order to enrich the lives of the people in support of certain social welfare undertakings, North Tower, the city set up a lottery. Rules of the lottery are:

(1) printed on each lottery ticket has seven different numbers, and these numbers fetch ranges from 1 to 33.

(2) each time before the awarding of seven will publish a different number consisting of the winning numbers.

(3) set up a total of seven prizes, grand prize and first prize to Liu Dengjiang. Duijiang rules are as follows:

Grand Prize: the requirements of the lottery numbers appear in seven winning numbers.

First prize: the required number appears in the lottery six winning numbers.

Second prize: the required number appears in the lottery five winning numbers in.

Third prize: the required number appears in the lottery four winning numbers.

Fourth Prize: requires the lottery three numbers appear in the winning numbers.

Fifth prize: require a lottery number appears in two of the winning numbers.

Liu Dengjiang: requires the lottery numbers appear in a winning number.

Note: does not consider the number and location of the winning lottery numbers on each number appears Duijiang. For example, the winning number is 2331114191718, the lottery 1289231167 due wherein there are two numbers (1 and 23) appear in the winning numbers, so the five lottery prize.

It is known that the winning numbers and Zhang Xiaoming buy some lottery numbers, you write a program to help Xiao Ming judge jackpot he bought lottery tickets.

Input Format

The first line of the file is only a natural number n (n <1000), indicates the number of sheets Xiaoming buy lottery tickets;

The second line store 7 a natural number between between 1 and 33, showing the winning numbers;

In each subsequent row n-th row has 7 interposed natural number between 1 and 33, respectively, Xiaoming n lottery ticket bought.

Output Format

Jackpot sequentially output Xiao Ming bought lottery tickets (the number of winning), the first output of the number of Grand Prize winner Zhang, followed by the output number of sheets of winning the first prize to Liu Dengjiang of.

Sample input and output

Input # 1
2
23 31 1 14 19 17 18
12 8 9 23 1 16 7
11 7 10 21 2 9 31
Output # 1
0000011 

This question is in fact no difficulty, came out to look at the statistics, but the foundation, the most important is to build confidence and develop programming ideas! ! !
 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 int n,aim[10101],pr[10];
 6 
 7 int main()
 8 {
 9     cin>>n;
10     for(int i=1;i<=7;i++)
11     {
12         int x; cin>>x;
13         aim[x]++;
14     }
15     for(int i=1;i<=n;i++)
16     {
17         int t=0;
18         for(int j=1;j<=7;j++)
19         {
20             int x; cin>>x;
21             if(aim[x]) t++;
22         }
23         pr[t]++;
24     }
25     for(int i=7;i>0;i--)
26     cout<<pr[i]<<" ";
27     cout<<endl;
28     return 0;
29 }

Lay a solid foundation, do a good job each question! ! !

Author: Gmax

This article belongs to the author and blog Park total, reproduced, please use the link, please do not reprint the original, Thanks ♪ (· ω ·) Techno

Guess you like

Origin www.cnblogs.com/Gmax/p/11330752.html