博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LightOJ - 1148 - Mad Counting
阅读量:5011 次
发布时间:2019-06-12

本文共 1740 字,大约阅读时间需要 5 分钟。

先上题目:

1148 - Mad Counting
 
Time Limit: 0.5 second(s) Memory Limit: 32 MB

Mob was hijacked by the mayor of the Town "TruthTown". Mayor wants Mob to count the total population of the town. Now the naive approach to this problem will be counting people one by one. But as we all know Mob is a bit lazy, so he is finding some other approach so that the time will be minimized. Suddenly he found a poll result of that town where N people were asked "How many people in this town other than yourself support the same team as you in the FIFA world CUP 2010?" Now Mob wants to know if he can find the minimum possible population of the town from this statistics. Note that no people were asked the question more than once.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with an integer N (1 ≤ N ≤ 50). The next line will contain N integers denoting the replies (0 to 106) of the people.

Output

For each case, print the case number and the minimum possible population of the town.

Sample Input

Output for Sample Input

2

4

1 1 2 2

1

0

Case 1: 5

Case 2: 1

 

  基础题,告诉你一个村子里面,某n个人支持他们支持的球队的村民(除了他自己以外)还有多少人,问村子里面至少有多少人。

  不多说,分析一下就可以出结果。

 

上代码:

1 #include 
2 #include
3 #include
4 #include
5 #define MAX 1000002 6 #define ll long long 7 using namespace std; 8 9 typedef pair
pii;10 11 ll s[52];12 pii p[52];13 14 int main()15 {16 int n,t,x,lo;17 ll ans;18 //freopen("data.txt","r",stdin);19 scanf("%d",&t);20 for(int z=1;z<=t;z++){21 scanf("%d",&n);22 for(int i=0;i
/*1148*/

 

 

转载于:https://www.cnblogs.com/sineatos/p/3905604.html

你可能感兴趣的文章
美女与硬币问题
查看>>
计算几何算法概览 (转)
查看>>
Notepad++的ftp远程编辑功能
查看>>
数据库多对多关联表(Python&MySQL)
查看>>
[实变函数]1.2 集合的运算
查看>>
第06天
查看>>
设计模式的征途—5.原型(Prototype)模式
查看>>
iOS10 app连接不上网络的问题
查看>>
结对开发之电梯调度最终稿(徐梦迪&刘博)
查看>>
simple java mail
查看>>
信息建模
查看>>
Mybatis 数据库物理分页插件 PageHelper
查看>>
虚函数、纯虚函数详解
查看>>
z-stack中数据的发送,广播、组播、点对点
查看>>
Practial Vim 学习笔记一
查看>>
.NET中使用js实现百度搜索下拉提示效果[不是局部刷新,呜呜。。]
查看>>
ITCAST视频-Spring学习笔记(使用Spring的注解方式实现AOP入门)
查看>>
关于二维码“QR”的6大注意事项
查看>>
MySQL - 常用命令及常用查询SQL
查看>>
C# .NET MVC 接收 JSON ,POST,WCF 无缝隙切换
查看>>