文章目录

  • 题目描述
    • 输入描述
    • 输出描述
    • 输入输出样例
    • 线索提示
  • 一、解题思路
  • 二、题解
    • 源代码
    • VJudge评判结果
  • 写在最后

题目描述

The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.

As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:

  • At least one participant should get a diploma.
  • None of those with score equal to zero should get awarded.
  • When someone is awarded, all participants with score not less than his score should also be awarded.
  • Determine the number of ways to choose a subset of participants that will receive the diplomas.

关键信息部分翻译:

  • 至少有一个参与者应该获得文凭。
  • 得分为零者不得获奖。
  • 当有人被奖励时,所有得分不低于他的参与者也应该被奖励
  • 确定选择一部分将获得文凭的参与者的方式的数量。

Setsuna wants to know the shortest time for the message to reach at least one of the stars after she sends it.

You can assume that Einstein’s theory of relativity doesn’t work in Setsuna’s world.


输入描述

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of participants.

The next line contains a sequence of n integers a1, a2, …, an (0 ≤ ai ≤ 600) — participants’ scores.

It’s guaranteed that at least one participant has non-zero score.


输出描述

Print a single integer — the desired number of ways.


输入输出样例

//Example1
//Input
4
1 3 3 2//Output
3
//Example2
//Input
3
1 1 1//Output
1
//Example3
//Input
4
42 0 0 42//Output
1

线索提示

There are three ways to choose a subset in sample case one.(对于线索1)

  • Only participants with 3 points will get diplomas.
  • Participants with 2 or 3 points will get diplomas.
  • Everyone will get a diploma!

The only option in sample case two is to award everyone.(对于线索二)

Note that in sample case three participants with zero scores cannot get anything.


一、解题思路

上面说了一大堆,翻译过来的人话就是:

给了你一堆分数,主要按照当有人被奖励时,所有得分不低于他的参与者也应该被奖励这一奖励方式对参赛者进行颁奖,喊你求有多少种颁奖的方式

其实,这道题目可以转化为求一个集合的子集的问题 (集合中没有重复元素,想想你和另外的一个同学考了98分,他有奖金,你也一定要有,换句话说,他拿到奖状就代表着你拿到奖状了,所以你们俩只需要那98这一个成绩出来和其他同学比一比就可以了)

对于这个要求,我们只需要用STL库中的set类型即可(具有自动去重功能)

我们于是举几个例子,就能够说明问题
如输入
6
0 1 2 3 3 4
则有4种不同的元素(除0,除重复)

  • 我们选4个同学获奖 >>>>> 有1种情况
  • 我们选3个同学获奖 >>>>> 有1种情况
  • 我们选2个同学获奖 >>>>> 有1种情况
  • 我们选1个同学获奖 >>>>> 有1种情况

所以,我们可以得到规律:
集合元素个数 ≡ 颁奖方案个数 \text{集合元素个数} \equiv \,\,\text{颁奖方案个数} 集合元素个数≡颁奖方案个数

我们只需要对每个范例逐一将元素添加进集合,最后用.size()输出元素个数即可


二、题解

源代码

代码如下:

/*
* Author:   FeverTwice
* Date:     2021-05-02
* Func:     Solution for Olympiad
*/#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <functional>
#include <set>#define debug(a) cout<<#a<<"="<<a<<endl;
#define lyh(i,a,b) for(int i=a;i<=b;i++)
#define hyl(i,a,b) for(int i=a;i>=b;i--)
#define LL long long
#define mm memset
#define EPS 1e-8
#define INF 0x7fffffff
using namespace std;set<int> stu;     //定义集合int main()
{int n;cin >> n;int temp;for (int i = 0; i < n; i++){cin >> temp;if (temp > 0) {stu.insert(temp);  //如果非零,往集合内添加元素}}cout << stu.size() << endl; //输出集合个数return 0;
}

VJudge评判结果


写在最后

各位看官,都看到这里了,麻烦动动手指头给博主来个点赞8,您的支持作者最大的创作动力哟! <(^-^)>
才疏学浅,若有纰漏,恳请斧正
本文章仅用于各位同志作为学习交流之用,不作任何商业用途,若涉及版权问题请速与作者联系,望悉知

Olympiad (奥林匹克信息赛) Visual Judge (Set3)相关推荐

  1. Cheat Sheet (小抄) Visual Judge (Set3)

    文章目录 题目描述 输入描述 输出描述 输入输出样例 线索提示 一.解题思路 二.题解 源代码 VJudge评判结果 参考文献 写在最后 题目描述 Cheat Sheet (小抄) Universit ...

  2. 高中生计算机竞赛培训,奥林匹克信息竞赛培训

    奥林匹克信息竞赛培训 传统的计算机.机器***多都是重要的工作岗位,除了家长必须用计算机编程和要求外,还要关心了解自己孩子的需求,这也是孩子的基本条件,有些孩子可能不是很认真的要求自己,比如要求孩子要 ...

  3. 2016合肥市第 33 届青少年信息学(计算机)奥林匹克竞 赛小学组试题

    1 .木板面积( area ) 在一个阳光明媚的清晨,卡卡西在老师的带领下来到了"神奇木材加工厂". 这个木材加工厂比较特别,工人们只制作圆形和长方形样式的木板,工厂的测量 工人每 ...

  4. Solution for Archmage(大法师)Visual Judge (Set 3)

    文章目录 题目描述 输入描述 输出描述 输入输出样例 线索提示 一.解题思路 观察易得 注意点 使用模拟? 数据类型 二.题解 源代码 VJudge评判结果 参考文献 写在最后 题目描述 Archma ...

  5. 在GCC和Visual Studio中使用hash_map

    熟悉STL或熟悉ACM/ICPC的话,其中的set, map, multiset, multimap一定用过无数次了,它们都是用平衡二叉树(红黑树)实现的,复杂度为O(lgn).我们也知道set, m ...

  6. JOJ——基于爬虫的在线测评系统(Online Judge)

    这是一个基于爬虫的在线测评系统(OJ). 相信喜欢刷题的各位大佬应该对OJ并不陌生.本系统旨在使用一个账号,就可以刷遍各个OJ的题目. 系统基于后端SpringBoot.Mybatis-Plus.Th ...

  7. 2014 ACM/ICPC 北京赛区网络赛解题报告汇总

    首页 算法竞赛» 信息聚合 ONLINE JUDGE 书刊杂志 BLOG» 新闻故事» 招聘信息» 投稿须知 2014 ACM/ICPC 北京赛区网络赛解题报告汇总 九月 21st, 2014 | P ...

  8. 【错误记录】Visual Studio 中编译 NDK 报错 ( error : cannot use ‘throw‘ with exceptions disabled )

    文章目录 一.报错信息 二.解决方案 一.报错信息 使用 Visual Studio 2019 编译 Android NDK 项目 , 报错如下 : 已启动生成- 1>------ 已启动生成: ...

  9. 【错误记录】Visual Studio 中编译 NDK 报错 ( no matching function for call to ‘cacheflush‘ cacheflush(); )

    文章目录 一.报错信息 二.报错信息 一.报错信息 使用 Visual Studio 2019 编译 Android 平台的 NDK 项目 ; 编译时报错 ; 报错信息 : 1>./native ...

最新文章

  1. 请问大侠maven怎么添加ms的jdbc驱动啊,1.6jdk
  2. ibatis查询CHAR类型的字段
  3. 机器学习项目开发经验
  4. 中缀/后缀/前缀表达式及相互转换的手算详细步骤及C代码实现
  5. cocos2dx 游戏中内存优化
  6. 探寻中国便携式医疗电子市场的机遇与挑战
  7. Javascrit通过百度地图API获取客户端IP、地址
  8. android微信登录用户绑定,微信授权登陆接入第三方App(步骤总结)Android
  9. html页面input框输入不了,input框不能输入问题
  10. 什么是连接池,其工作原理是什么?
  11. 服务器nvme硬盘识别不了,解决部分主板无法识别NVMe协议的固态硬盘问题
  12. 2022年全球市场筒仓称重系统总体规模、主要生产商、主要地区、产品和应用细分研究报告
  13. win7 右键添加 显示\隐藏 系统文件+扩展名
  14. 这份1658页的Java面试核心突击讲,成功让我上岸阿里
  15. 一步一步做ListView滚动固定头部并且头部会变化哦
  16. 常用3500个汉字(转收藏)
  17. TP-link TL-R473G配置pppoe账号分配网络上网
  18. mac上连接魅族手机
  19. 阿里云OCR图片识别使用流程
  20. asp.net图书销售管理系统

热门文章

  1. 敏捷 | 如何正确理解敏捷?
  2. 【实用技巧分享】使用ADB工具删除手机自带应用
  3. iphone计算机显示算式,在 iPhone 上的 Numbers 表格中计算值
  4. 技术宅小伙:Angular入门 - ngIf和ngFor介绍
  5. 介绍snipaste截图快捷键
  6. 全球与中国汽油滤清器市场深度研究分析报告
  7. patch文件中各参数的意义
  8. 淘宝首页 图片滑动切换效果 基于CSS3的transition方法实现
  9. 跨线程调用控件之MethodInvoker
  10. Python爬虫,私活接单记录,假日到手5500,美滋滋