HDOJ-1004(map)】的更多相关文章

hdoj 1004题目大概讲的是,将输入的字符串根据输入次数多少,输出出现次数最多的字符串. 题目逻辑很简单,就是需要选择相应的数据结构,看了别人提交的discuss,明显发现可以使用多种数据结构解这道题. 其实我本是打算用结构体来解的,但是结构体还是不太熟,并又看了别人的代码就不在自行考虑了. 关键是用两个数组,一个是 char boloon[1000][16] ,另一个是 int num[1000] , 取1000是因为输入要求N(0<N ≤ 1000), 16 是因为输入字符串大小在0~1…
Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color…
T1000 #include <stdio.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) printf("%d\n", a + b); ; } T1001 #include <stdio.h> #ifdef AUTHOR Code By Hatsuakira Tenan #endif int f(int n) { ; ; --n) js += n…
强大的MAP,今天终于开始好好学习一次. map内部是用红黑树维持的有序结构. 定义:map<int,string>mapStudent; 查找的时间复杂度为对数级别. 1.构造方法学习两种: 第一种:用insert函数插入pair数据,mapStudent.insert(pair<int, string>(0,"jiangjing")); 第二种:用数组方式插入数据 mapStudent[1] = "jiangjing1";  mapStu…
题目: Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each co…
Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color…
1. string对象的定义和初始化以及读写 string s1; 默认构造函数,s1为空串string s2(s1); 将s2初始化为s1的一个副本string s3("valuee"); 将s3初始化一个字符串面值副本string s4(n,'c'); 将s4 初始化为字符'c'的n个副本cin>>s5; 读取有效字符到遇到空格getline(cin,s6); 读取字符到遇到换行,空格可读入,遇'\n'结束getline(cin,s7,'a'); 遇'a'结束,其中任何…
在学习c++STL中的string,在这里做个笔记,以供自己以后翻阅和初学者参考. 1:string对象的定义和初始化以及读写 string s1;      默认构造函数,s1为空串 string s2(s1);   将s2初始化为s1的一个副本 string s3("valuee");   将s3初始化一个字符串面值副本 string s4(n,'c');   将s4 初始化为字符'c'的n个副本 cin>>s5;  读取有效字符到遇到空格 getline(cin,s6…
本文直接转载,非原创!仅记录供自己学习之用. 出处:http://blog.csdn.net/y990041769/article/details/8763366 在学习c++STL中的string,在这里做个笔记,以供自己以后翻阅和初学者参考. 1:string对象的定义和初始化以及读写 string s1;      默认构造函数,s1为空串 string s2(s1);   将s2初始化为s1的一个副本 string s3("valuee");   将s3初始化一个字符串面值副本…
1.TreeMap集合倒序排列 import java.util.Comparator; /** * 比较算法的类,比较器 * @author Administrator * */ public class MyCmp implements Comparator<Object> { // 实现倒序 @Override public int compare(Object o1, Object o2) { int x = o2.toString().compareTo(o1.toString())…