链接:

https://vjudge.net/problem/LightOJ-1148

题意:

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.

思路:

报数n的人,最多n+1个组成一队,取最优计算

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; map<int, int> Mp; int main()
{
int t, cnt = 0;
int n, x, v;
scanf("%d", &t);
while(t--)
{
Mp.clear();
scanf("%d", &n);
printf("Case %d: ", ++cnt);
for (int i = 1;i <= n;i++)
{
scanf("%d", &v);
Mp[v]++;
}
int sum = 0;
for (auto v: Mp)
{
sum += ((v.second+v.first)/(v.first+1))*(v.first+1);
}
printf("%d\n", sum);
} return 0;
}

LightOJ - 1148-Mad Counting (数学)的更多相关文章

  1. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

  2. LightOJ - 1148 - Mad Counting

    先上题目: 1148 - Mad Counting   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 3 ...

  3. 1148 - Mad Counting(数学)

    1148 - Mad Counting   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB M ...

  4. light oj 1148 - Mad Counting

    1148 - Mad Counting   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB M ...

  5. LightOj 1148 Basic Math

    1148 - Mad Counting PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB Mob ...

  6. LightOJ - 1058 - Parallelogram Counting(数学,计算几何)

    链接: https://vjudge.net/problem/LightOJ-1058 题意: There are n distinct points in the plane, given by t ...

  7. Codeforces 911D. Inversion Counting (数学、思维)

    题目链接:Inversion Counting 题意: 定义数列{ai|i=1,2,...,n}的逆序对如下:对于所有的1≤j<i≤n,若ai<aj,则<i,j>为一个逆序对. ...

  8. LightOJ 1058 - Parallelogram Counting 几何思维

    http://www.lightoj.com/volume_showproblem.php?problem=1058 题意:给你顶点,问能够成多少个平行四边形. 思路:开始想使用长度来扫描有多少根,但 ...

  9. 17997 Simple Counting 数学

    17997 Simple Counting 时间限制:2000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: 不限定 Description Ly is craz ...

  10. UVA 11401 - Triangle CountingTriangle Counting 数学

    You are given n rods of length 1,2, . . . , n. You have to pick any 3 of them and build a triangle. ...

随机推荐

  1. 033 Android App启动的闪屏效果+新手向导(多个图片滑动效果)+ViewPager使用

    1.目标效果 App启动时,出现闪屏效果(利用动画实现). App新手使用时,会出现新手向导效果. 2.XML页面布局 (1)闪屏页面 <?xml version="1.0" ...

  2. 人工智能对人类有哪些影响 选择Python入门怎样

    人工智能对人类有哪些影响?选择Python入门怎样?人工智能是科技时代进步的产物,也是目前人们非常关注的一个产业.那么,随着人工智能的发展,对人类生活的有哪些影响呢? 1.人工智能对文化产业影响 据了 ...

  3. 解决idea中maven项目无法读取src/main/java目录下面的配置文件问题

    解决idea中maven项目无法读取src/main/java目录下面的配置文件问题 当我们在maven项目中使用Mybatis的时候,需要给Mybatis配置核心xml文件(MyBatis-Conf ...

  4. 关于JavaScript 基础总结

    Dom:document object model 即文档对象模型 Bom: browser object model 即浏览器对象模型 文档对象模型即与文本密切相关,比如document.query ...

  5. 【SCALA】1、我要开始学习scala啦

    因为scala也是基于jvm上运行的,所以能跑java,原则上就能跑scala 1.国际惯例,先来个hello world走走 package demo1 //object之下全为静态,scala没有 ...

  6. PHP Math常量

    常量名 常量名 常量值 PHP M_E e 2.7182818284590452354 4 M_EULER Euler 常量 0.57721566490153286061 5.2.0 M_LNPI l ...

  7. linux之rename和mv的区别

    rename 命令格式 rename [ -v ] [ -n ] [ -f ] perlexpr [ files ] 参数介绍 -v:被替换掉的字符串 -n:替换成的字符串 -f:匹配要替换的文件模式 ...

  8. Java QuickSelect

    Java QuickSelect /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternationa ...

  9. MySQL LAST_INSERT_ID()用法

    last_insert_id()函数是适用于id为自动生成的表 下面是插入表数据时last_insert_id()函数的两种用法: 表结构: 此表使用last_insert_id()函数的字段为par ...

  10. kafka的安装及使用(单节点)

    介绍了linux环境下,kafka 服务的安装与配置 安装 jdk 环境 下载 kafka 源码包放到服务器,解压 开启 zookeeper 开启 kafka server 创建主题 开启生产者 开启 ...