[2016-01-19][POJ][1002]

  • [2016-01-19][ACM][POJ 1002]
  • 题目大意:给定一串号码,转化号码,然后输出重复的号码.  
  • 方法:读取->转换->计数->输出  
  • 解题过程遇到问题:  
    • cin,cout貌似会WA(原因不详)
    • 数组开太小,wa成dog,开到50能过.
    • 忘记输出,No duplicates.的情况
    • 不知道 map 自带排序,手动实现了一遍,2333

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cctype>

#include <string>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

using namespace std;

struct dataa{

    char str[50];

    bool operator < (const dataa & a)const{

        return strcmp(a.str,str)>0;

    }

}data[100010];

int main()

{

    map<char,char> m;

    m[‘1‘] = ‘1‘;

    m[‘0‘] = ‘0‘;

    m[‘A‘] = m[‘B‘] = m[‘C‘] = m[‘2‘] = ‘2‘;

    m[‘D‘] = m[‘E‘] = m[‘F‘] = m[‘3‘] = ‘3‘;

    m[‘G‘] = m[‘H‘] = m[‘I‘] = m[‘4‘] = ‘4‘;

    m[‘J‘] = m[‘K‘] = m[‘L‘] = m[‘5‘] = ‘5‘;

    m[‘M‘] = m[‘N‘] = m[‘O‘] = m[‘6‘] = ‘6‘;

    m[‘P‘] = m[‘R‘] = m[‘S‘] = m[‘7‘] = ‘7‘;

    m[‘T‘] = m[‘U‘] = m[‘V‘] = m[‘8‘] = ‘8‘;

    m[‘W‘] = m[‘X‘] = m[‘Y‘] = m[‘9‘] = ‘9‘;

    m[‘-‘] = m[‘Q‘] = m[‘Z‘] = ‘-‘;

    char str[50];int t;

    scanf("%d",&t);

    for(int i = 0 ; i < t ;i++){

        scanf("%s",str);

        char *p = str;

        int pos = 0;

        while(*p){

            if(pos == 3)

                data[i].str[pos++] = ‘-‘;

            if(m[*p] != ‘-‘)

                data[i].str[pos++] = m[*p];

            p++;

        }  

    }

    sort(data,data + t);

    int ct = 1;

    int kk = 0;

    for(int i = 1 ; i < t ;i++){

        if(!(data[i] < data[i-1]) && !(data[i-1] < data[i]))

            ct++;

        else if(ct  > 1){

            printf("%s %d\n",data[i - 1].str,ct);

            kk++;

            ct = 1;

        }

    }

    if(ct  > 1){

            printf("%s %d\n",data[t- 1].str,ct);

            kk++;

            ct = 1;

    }

    if(!kk) printf("No duplicates.\n");

    return 0;

}






1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cctype>

#include <string>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

    map<char,char> m;

    map<string,int> mp;

    m[‘1‘] = ‘1‘;m[‘0‘] = ‘0‘;

    m[‘A‘] = m[‘B‘] = m[‘C‘] = m[‘2‘] = ‘2‘;

    m[‘D‘] = m[‘E‘] = m[‘F‘] = m[‘3‘] = ‘3‘;

    m[‘G‘] = m[‘H‘] = m[‘I‘] = m[‘4‘] = ‘4‘;

    m[‘J‘] = m[‘K‘] = m[‘L‘] = m[‘5‘] = ‘5‘;

    m[‘M‘] = m[‘N‘] = m[‘O‘] = m[‘6‘] = ‘6‘;

    m[‘P‘] = m[‘R‘] = m[‘S‘] = m[‘7‘] = ‘7‘;

    m[‘T‘] = m[‘U‘] = m[‘V‘] = m[‘8‘] = ‘8‘;

    m[‘W‘] = m[‘X‘] = m[‘Y‘] = m[‘9‘] = ‘9‘;

    m[‘-‘] = m[‘Q‘] = m[‘Z‘] = ‘-‘;

    char str[50];

    int t;

    scanf("%d",&t);

    for(int i = 0 ; i < t ;i++)

    {

        scanf("%s",str);

        char *p = str;

        char tmp[50];

        int pos = 0;

        while(*p)

        {

            if(pos == 3)

            {

                tmp[pos++] = ‘-‘;

            }

            if(m[*p] != ‘-‘)

                tmp[pos++] = m[*p];

            p++;

        }

        tmp[pos] = ‘\0‘;

        mp[string(tmp)]++;

    }

    int kk = 0;

    map<string,int>::iterator it;

    for(it = mp.begin();it != mp.end();it++)

    {

        if(it->second > 1){

            printf("%s %d\n",(it->first).data(),it->second);

            kk++;

        }

    }

    if(!kk) printf("No duplicates.\n");

    return 0;

}

来自为知笔记(Wiz)

时间: 2025-01-17 23:44:17

[2016-01-19][POJ][1002]的相关文章

2016.01.19 UITextField

1.placeholder(占位符,就是默认提示文本) eg:_loginTextField.placeholder = @"QQ号/手机号/邮箱"; 2.borderStyle(设置边框类型) eg:_loginTextField.borderStyle = UITextBorderStyleRoundedRect; 各种类型: typedef NS_ENUM(NSInteger, UITextBorderStyle) { UITextBorderStyleNone, UITextB

2016.01.19 UIImageView

UIImageView是在界面上显示图片的一个控件. 1.contentMode 当图片的大小和控件的大小不一致的时候,就会调用到这个属性.这个属性是用来设置图片的显示方式,如居中.居右,是否缩放等,有以下几个常量可供设定: UIViewContentModeScaleToFill : 拉伸填充到整个控件大小 UIViewContentModeScaleAspectFit 保持图片的原始比例缩放,保证整个图片都在空间中的前提,横向或纵向一方填满整个屏幕 UIViewContentModeScal

2016.01.18-2016.01.21盲审通关修改

请以上同学在1月21日(星期四)之前将以下材料交到研究生科: 1.装订好的硕士学位论文3本(注意:封面上作者姓名和指导教师隐去.致谢隐去.硕士学位期间发表的全部的论文作者隐去): 2.普通信封上写明评阅费:200元.邮寄费:22元,并将相应的钱款分别装入以上三个信封(普通信封,一共:200*3+22*3元): 3.从研究生管理信息系统中导出的“论文评阅书”封面上的作者姓名和指导教师姓名隐去:交三份“论文评阅书”和三份“学位论文评阅聘书”. 4.交三份“EMS”信封和一个装有20×3=60元邮寄费

[官方软件] Easy Sysprep v4.3.29.602 【系统封装部署利器】(2016.01.22)--skyfree大神

[官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) Skyfree 发表于 2016-1-22 13:55:55 https://www.itsk.com/forum.php?mod=viewthread&tid=362766&highlight=Easy%2BSysprep [官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) [Easy Sysprep]概述:Easy Sy

[再做01背包] POJ 3624 Charm Bracelet

接触动态规划的第一题是数塔问题,第二题就是01背包问题了. 当时看的懵懵懂懂,回过头来再看这道题还是非常简单的了. 用 dp[i][j] 表示取前i种物品,使它们总体积不超过j的最优取法取得的价值总和状态转移方程:dp[i][j] = max(dp[i-1][j],dp[i-1][j-cost[i]]+weight[i]) 1 //#define LOCAL 2 #include <iostream> 3 #include <cstdio> 4 #include <cstri

poj 1002:487-3279(水题,提高题 / hash)

487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 236746   Accepted: 41288 Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phras

Murano Weekly Meeting 2016.07.19

Meeting time: 2016.July.19 1:00~2:00 Chairperson:  Kirill Zaitsev, from Mirantis Meeting summary: 1.Backports Link:  https://etherpad.openstack.org/p/murano-stable-backports/ 2.Convergence so both of our CI servers are running heat with convergence n

2016.01工作日志

2016.01.01 元旦在家,八点醒,开始继续阅读「30日でできる!OS自作入門」.主要目的,加深对os和cpu的理解.另外花些时间又重温王爽的<汇编语言>.今天,最大收获还是感官上体会系统底层:比如往内存xxxx里写入0或者1就可以实现操作系统对xxxx部件的控制.另外,看到了「30日でできる!OS自作入門」中自制操作系统的内存图,就可以知道,内存这种东西,就是操作系统,或者cpu规划的.内存本身是不分段的.内存的哪一段是ram哪一段是bios显卡,改变其地址值就可以实现特定效果. 对于这

2016.1.19 DEV Express控件GirdControl使用

DEV控件在工具箱中消失处理方法 开始-->程序-->Developer Express v2009 vol 3(依据版本不同)-->Components-->Tools-->ToolboxCreator   1.点击一行选择完整一行 Run Designer->View->OptionsBehavior->EditorShowMode 设置为:Click Run Designer->View->OptionsSelection.EnableAp