hdu 1800 Flying to the Mars (map)(暴力)
来源:互联网 发布:淘宝如何完成实名认证 编辑:程序博客网 时间:2024/06/03 14:33
map
//输入一堆数字 看一堆数中最少有多少个上升子串(不连续的子串)//每个串去掉一串最长的 再去掉一串次长的。//到最后肯定剩下某个出现次数最多的数字? //所以本题就是找那个数字出现的最多 最多的次数是多少//因为数太大数组存不下 所以用map# include<stdio.h># include<map># include<algorithm># include <string>using namespace std;int main(){int n;__int64 a,max;map<__int64,__int64>q;while(~scanf("%d",&n)){q.clear();while(n--){scanf("%I64d",&a);q[a]++;}map<__int64,__int64>::iterator it;max=0; //it->first 为a,it->second为 q[]++; //iterator->first 关键字(key) //iterator->second 存储的数据(value)for(it=q.begin();it!=q.end();it++){if(max<it->second)max=it->second;} printf("%I64d\n",max);}return 0;}
暴力
# include <stdio.h># include <string># include <algorithm>using namespace std;int main(){ int a[3010],flag[3010]; int n,i,min,cot,count; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); memset(flag,0,sizeof(flag)); cot=0; count=0; while(1) { cot++; for(i=0;i<n;i++) { if(!flag[i]) { min=a[i]; flag[i]=1; count++; break; } } for(i=0;i<n;i++) { if(!flag[i]&&a[i]>min) { min=a[i]; flag[i]=1; count++; } } if(count==n) { printf("%d\n",cot); break; } } } return 0;}
1 0
- hdu 1800 Flying to the Mars (map)(暴力)
- HDU 1800--Flying to the Mars【map】
- hdu 1800 Flying to the Mars 暴力解决
- HDU 1800 Flying to the Mars map水题
- hdu 1800 Flying to the Mars map的基本用法
- [字典树、map] HDU 1800 - Flying to the Mars
- HDU 1800 Flying to the Mars( map or hash )
- hdu 1800 Flying to the Mars(map简单题)
- Hdu oj 1800 Flying to the Mars(Map)
- 【HDU 1800】Flying to the Mars(STL map)
- Flying to the Mars (hash) 1800 hdu
- hdu 1800 Flying to the Mars
- Hdu-1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- HDU-1800-Flying to the Mars
- hdu 1800 Flying to the Mars
- hdu 1800 Flying to the Mars
- Makefile经典教
- 【HDU】3061 Battle 最大权闭合子图
- hdu 1845 Jimmy’s Assignment (二分图)
- 【拓扑排序】HDU 1285--- 确定比赛名次
- 山东理工OJ【2121】数据结构实验之链表六:有序链表的建立(插排法)
- hdu 1800 Flying to the Mars (map)(暴力)
- 在 Ubuntu 14.04 Server 上安装部署 Ruby on Rails 应用
- 50道Java习题之14
- 老鼠试毒算法
- HDU 4864 Task(贪心,输出利润的最大值)
- UVA10148- Advertisement(区间选点)
- 在本机使用不同版本VS编译boost
- hdu-1203-I NEED A OFFER!
- hdu_2574 Hdu Girls' Day