Skip to content

P2550 [AHOI2001] 彩票摇奖 #4

@RyanHe0

Description

@RyanHe0

[AHOI2001] 彩票摇奖

题目描述

为了丰富人民群众的生活、支持某些社会公益事业,北塔市设置了一项彩票。该彩票的规则是:

  1. 每张彩票上印有 $7$ 个各不相同的号码,且这些号码的取值范围为 $1\sim33$
  2. 每次在兑奖前都会公布一个由七个各不相同的号码构成的中奖号码。
  3. 共设置 $7$ 个奖项,特等奖和一等奖至六等奖。

兑奖规则如下:

  • 特等奖:要求彩票上 $7$ 个号码都出现在中奖号码中。
  • 一等奖:要求彩票上有 $6$ 个号码出现在中奖号码中。
  • 二等奖:要求彩票上有 $5$ 个号码出现在中奖号码中。
  • 三等奖:要求彩票上有 $4$ 个号码出现在中奖号码中。
  • 四等奖:要求彩票上有 $3$ 个号码出现在中奖号码中。
  • 五等奖:要求彩票上有 $2$ 个号码出现在中奖号码中。
  • 六等奖:要求彩票上有 $1$ 个号码出现在中奖号码中。

注:兑奖时并不考虑彩票上的号码和中奖号码中的各个号码出现的位置。例如,中奖号码为 $23\ 31\ 1\ 14\ 19\ 17\ 18$,则彩票 $12\ 8\ 9\ 23\ 1\ 16\ 7$ 由于其中有两个号码($23$ 和 $1$)出现在中奖号码中,所以该彩票中了五等奖。

现已知中奖号码和小明买的若干张彩票的号码,请你写一个程序帮助小明判断他买的彩票的中奖情况。

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[10],b[10],c[10],cnt,ans[10]={0};
	cin>>n;
	for (int i=0;i<7;i++) cin>>a[i];
	while(n--){
		cnt=0;
		for (int i=0;i<7;i++) cin>>b[i];
		for (int i=0;i<7;i++){
		
			for (int j=0;j<7;j++){
			
				if (a[i]==b[j]) cnt++;
			}
}
		ans[7-cnt]++;

		
	}
	for (int i=0;i<7;i++) cout<<ans[i]<<" "; 
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions