水题/hdu 1004 Let the Balloon Rise

题意

  给出n个字符串,输出出现次数最多的那个

分析

  存下字符串后排序,再统计,输出

Accepted Code

 1 /*
 2     PROBLEM:hdu1004
 3     AUTHER:Nicole Lam
 4     MEMO:水题
 5 */
 6
 7 #include<iostream>
 8 #include<cstring>
 9 #include<string>
10 #include<algorithm>
11 using namespace std;
12
13 int main()
14 {
15     int n;
16     cin>>n;
17     while (n!=0)
18     {
19         string a[1010];
20         int num[1010];
21         for (int i=1;i<=n;i++) cin>>a[i];
22         sort(a+1,a+n+1);
23         for (int i=1;i<=n;i++) num[i]=1;
24         int ans=1;
25         for (int i=2;i<=n;i++)
26         {
27             if (a[i]==a[i-1]) num[i]+=num[i-1];
28             if (num[i]>=num[ans]) ans=i;
29         }
30         cout<<a[ans]<<endl;
31         cin>>n;
32     }
33     return 0;
34 }
时间: 2024-10-25 19:05:46

水题/hdu 1004 Let the Balloon Rise的相关文章

HDU 1004 Let the Balloon Rise【STL&lt;map&gt;】

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123800    Accepted Submission(s): 48826 Problem Description Contest time again! How excited it is to see balloons floating ar

hdu 1004 Let the Balloon Rise

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 80469    Accepted Submission(s): 30293 Problem Description Contest time again! How excited it is to see balloons floating aro

HDU 1004 Let the Balloon Rise map

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 104108    Accepted Submission(s): 40046 Problem Description Contest time again! How excited it is to see balloons floating ar

HDU 1004 Let the Balloon Rise (map使用)

分析:题意简单,就用map的知识即可 #include <stdio.h> #include <iostream> #include <string.h> #include <map> using namespace std; int main() { int i,a,b,k; int N; char num[10]; while (~scanf("%d",&N)) { map<string,int> mp; whil

hdu 1004 Let the Balloon Rise(STL)

1代码: #include<set> #include<string> #include<cstring> #include<cstdio> #include<iostream> using namespace std; set<string> st; multiset<string> mst; int main() { int n; string s; while(scanf("%d",&n)

hdoj 1004 Let the Balloon Rise(模拟 || 字典树)

Let the Balloon Rise http://acm.hdu.edu.cn/showproblem.php?pid=1004 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 84401    Accepted Submission(s): 31831 Problem Description Contest time again

杭电1004 Let the Balloon Rise

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 120507    Accepted Submission(s): 47270 Problem Description Contest time again! How excited it is to see balloons floating ar

水题/hdu 1012 u Calculate e

题意 求n=0~9时的sigma(1/n!) 分析 因为刚学c++ 所以对浮点操作还是很不熟练,正好来了这么一道题 Accepted Code 1 /* 2 PROBLEM:hdu 1012 3 AUTHER:Nicole Lam 4 MEMO:水题 5 */ 6 #include<iostream> 7 #include<iomanip> 8 using namespace std; 9 double a[10]; 10 int main() 11 { 12 cout<&l

HDOJ 1004 - Let the Balloon Rise(让气球飞起来)

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 138223    Accepted Submission(s): 54591 Problem Description Contest time again! How excited it is to see balloons floating ar