校赛E 统计
来源:互联网 发布:淘宝站外网站 编辑:程序博客网 时间:2024/06/08 18:23
Youcai Li is a student and he like to chat with girls usually. In order to know which girl he talked with, he numbers these girls, so each girl has her own individual number. For instance, Miss.Leilei Wang's number is 1. Miss.Xiaolei Wang's number is 2.
All input numbers are integers.
The first line is a integer n (1 <= n <= 105 )means how many times Mr.Li talk with girls.
Next line contains n integers representing the number of girls. ( 1 <= numberi <= 88888888)
Can you tell me which girl Mr.Li talk with the most frequently? please output two integers:
p represent the number of the girl.
m reoresent how many times Mr.Li talk with the girl.
10
8 7 5 4 9 1 5 5 4 1
5 3
In this sample, Mr.Li talk with 5th girl most frequently and he talk with the girl for 3 times!
这题是英文题,题目比较水,只要能翻译正确,基本上没什么太大的问题。大概意思就是输入n,代表输入n个数,在输入的数里面找出出现此数的数,输出这个数,并且输出这个数出现的次数。这题可以直接选用sort排序。
#include<stdio.h>#include<algorithm>#include<iostream>using namespace std;int a[110000];int main(){ int n; while(scanf("%d",&n)!=EOF) { int i,temp=1,max=0,m;//因为出现的数字次数最少是1,所以temp为1 for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); for(i=0;i<(n-1);i++) { if(a[i]==a[i+1]) temp++;//如果后面的数等于前面的数,则temp加1. else temp=1;//如果不等于,重置temp. if(max<=temp) { max=temp; m=i; } } printf("%d %d\n",a[m],max); } return 0;}
- 校赛E 统计
- 根据ID统计分数求最高分-E
- 【codevs1453 统计素数个数2】E氏筛法
- 【暑期基础2】E HDU 汉字统计(汉字)
- 陆金所—稳盈-e享统计-python爬虫
- codeforces 558E E. A Simple Task( 线段树+统计排序)
- 《行为科学统计7e(Statistics for the Behavioral Sciences 10e)》 Introduction to Statistics
- ZCMU-校赛E-1780
- e
- E
- E
- e
- e
- e
- e
- e
- E
- e
- 异或运算及其应用
- 关于Installshield里一些常见问题的解答—艾泽拉斯之海洋女神出品
- ubuntu bochs环境
- JAVA事务,JTA,JDBC,JDO,DAO,JNDI概念
- Reverse Words in a String
- 校赛E 统计
- C++考后小悟
- MySQL slave error 1677
- qsort函数
- 【Linux Bash】利用管道简化sudo 密码的输入操作
- 如何让FPGA中的SPI与其他模块互动起来
- 2014-2015 -2016 新记录 新笔记 新起点
- Maximal Rectangle
- Android自定义xmlns报错及解决办法