题目链接

思路

开个一千万的数组计数,最后遍历即可。

#include<stdio.h>
#include<string.h>
#include<algorithm> using namespace std;
int num=0;
int mymap[10000000] = {0}; int change(char a[201])
{
int j=0, result=0;
for(int i=0;i<strlen(a);i++)
{
if(a[i] == '-') continue;
if(a[i] <= '9' && a[i] >= '0')
{
result = result*10+a[i]-'0';
continue;
}
if( a[i] <= 'O' && a[i] >= 'A' )
{
result = result*10+ (int)((a[i]-'A')/3) + 2;
continue;
}
switch (a[i])
{
case 'P':
case 'R':
case 'S':
result = result*10+7;
break;
case 'T':
case 'U':
case 'V':
result = result*10+8;
break;
case 'W':
case 'X':
case 'Y':
result = result*10+9;
break;
}
}
return result;
}
int main()
{
int n,times=0;
char temp[201];
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s",temp);
int flag = 0, t;
t = change(temp);
mymap[t] ++;
} int flag = 0;
for(int i=0;i<10000000;i++)
{
if(mymap[i] < 2) continue;
flag = 1;
char p[8] = {0};
sprintf(p,"%d",i);
if( strlen(p) <= 4 )
{
for(int j=0;j<3;j++)
printf("0");
printf("-");
for(int j=0;j<4-strlen(p);j++)
printf("0");
for(int j=0;j<strlen(p);j++)
printf("%c",p[j]);
}
else
{
for(int j=0;j<7-strlen(p);j++)
printf("0");
for(int j=0;j<strlen(p)-4;j++)
printf("%c",p[j]);
printf("-");
for(int j=strlen(p)-4;j<strlen(p);j++)
printf("%c",p[j]);
}
printf(" %d\n",mymap[i]);
}
if( flag == 0 ) puts("No duplicates.");
return 0;
}

百炼OJ - 1002 - 方便记忆的电话号码的更多相关文章

  1. PKU OJ 1002 487-3279

    PKU OJ 1002 487-3279 487-3279 Description Businesses like to have memorable telephone numbers. One w ...

  2. 九度OJ 1002:Grading

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:18410 解决:4753 题目描述: Grading hundreds of thousands of Graduate Entrance ...

  3. Light oj 1002 Country Roads (Dijkstra)

    题目连接: http://www.lightoj.com/volume_showproblem.php?problem=1002 题目描述: 有n个城市,从0到n-1开始编号,n个城市之间有m条边,中 ...

  4. OJ#1002 又是a+b

    题目描述: 给定两个正整数a.b(0 < a,b < =10000),求出a+b的和 输入描述: 多组输入,每组输入为一行,里面有2个数a,b(0 < a,b < =10000 ...

  5. oj 1002题 (大数题)

    #include <stdio.h> #include <string.h> int main(void) { int q,j,h,k,l; int d; ],s2[];//题 ...

  6. 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题

    #include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...

  7. 杭电oj 1002

    #include <iostream> #include <algorithm> using namespace std; int nCases; ], n[]; ], b[] ...

  8. PKU 百炼OJ 简单密码

    http://bailian.openjudge.cn/practice/2767/ #include<iostream> #include <cmath> #include ...

  9. PKU 百炼OJ 奖学金

    http://bailian.openjudge.cn/ss2017/A/ #include<iostream> #include <cmath> #include <m ...

随机推荐

  1. Django 查看原生的sql语句

    python manage.py sqlmigrate your_app_name 0001 把your_app_name换成自己的app名字即可看到框架自动生成的创建表sql语句,于是我就这样看到了 ...

  2. Oracle 中关于 Group By 子句与多行函数嵌套搭配使用的注意事项

    目录 你需要知道的 啥叫单行函数 啥叫多行函数 如何理解这个概念 Group by 子句使用规则 看一道 071 考题 你需要知道的 提到 Group by 子句,你需要先理解一个东西:函数的分类.提 ...

  3. JN_0009:win下快捷键注销,关机,重启

    注销:  wn + x  + U  再按 I 键 关机: win + x  + U  再按 U 键 重启: win + x  + U  再按 R 键

  4. 日常问题--解决 ‘Could not fetch URL https://pypi.python.org’的问题

    难题描述: 解决方法: 使用命令python -m pip install Scrapy  --trusted-host=pypi.python.org --trusted-host=pypi.org ...

  5. Vuex项目实战store

    首先简单了解一下什么是Vuex? Vuex是一个专为Vue.js应用程序开发的状态管理模式.采用集中式存储来管理应用所有组件的状态. 以下是对vuex的使用的简单介绍: 一.安装 npm i vuex ...

  6. 部件MSCOMCTL.OCX或其附件之一不能正确注册:一个文件丢失或无效

    部件MSCOMCTL.OCX或其附件之一不能正确注册:一个文件丢失或无效: https://blog.csdn.net/yilese/article/details/71479908

  7. php环境安装问题

    1.如果图标是黄色,查看apache等服务是否全部启用:   2.如果启用了,查看80端口是否被占用->如果测试端口表明被占用->修改httpd.config文件:     1).Ctrl ...

  8. Selenium3+python自动化007-警告框

    警告框 alert = driver.switch_to.alert alert.text() alert.accpet() alert.dismiss() # 导selenium包 from sel ...

  9. Selenium自动化发送163邮箱

    自动化发送163邮件 方法一: import time import datetime from selenium import webdriver from selenium.webdriver.s ...

  10. IE浏览器复选框遍历不兼容问题

    obj = document.getElementsByName("userIdCheckbox"); ids = []; for(var k=0;k<obj.length; ...