Content

在一座城市中,每个人的电话号码都是由六位整数组成的,例如 11-45-14。

现在有 \(n\) 个人,第 \(i\) 个人有 \(s_i\) 个人的电话号码。已知:

  • 出租车司机的电话号码由六个相同的数字构成(如 66-66-66)。
  • 披萨外卖的电话号码由六个递减的数字构成(如 65-43-21)。
  • 其他的电话号码都是女生的。

现在给出这 \(n\) 个人所拥有的电话号码。众所周知,找一个拥有某种事情相关的人的电话号码最多的人办这件事总会很靠谱。你需要求出你在办某件事的时候应该找哪些人。

数据范围:\(1\leqslant n\leqslant 100\),\(0\leqslant s_i\leqslant 100\)。

Solution

这题是一道较为简单的模拟题。

我们利用 scanf 的特性,按照格式输入没个电话号码的六个数字,然后按照题目给出的规则将每个电话号码归入题目给出的类型中,同时统计每个人所拥有某种类型的电话号码的数量。

统计完以后,分别按照拥有某种类型的电话号码的数量降序排列,然后找出拥有和最多数量相同的人,最后再按照输入顺序输出即可。

Code

int n, num[107], cnt;
struct node {
string name;
int x[107][7], taxi, pizza, girl, id;
}a[107], ans1[107], ans2[107], ans3[107]; ib cmp1(const node& tmp1, const node& tmp2) {return tmp1.taxi > tmp2.taxi;}
ib cmp2(const node& tmp1, const node& tmp2) {return tmp1.pizza > tmp2.pizza;}
ib cmp3(const node& tmp1, const node& tmp2) {return tmp1.girl > tmp2.girl;}
ib cmpid(const node& tmp1, const node& tmp2) {return tmp1.id < tmp2.id;} int main() {
n = Rint;
F(i, 1, n) {
num[i] = Rint, a[i].id = i; cin >> a[i].name;
F(j, 1, num[i]) scanf("%1d%1d-%1d%1d-%1d%1d", &a[i].x[j][1], &a[i].x[j][2], &a[i].x[j][3], &a[i].x[j][4], &a[i].x[j][5], &a[i].x[j][6]);
}
F(i, 1, n) {
F(j, 1, num[i]) {
int fl1 = 1, fl2 = 1;
F(k, 1, 6) if(a[i].x[j][k] != a[i].x[j][1]) {fl1 = 0; break;}
F(k, 2, 6) if(a[i].x[j][k] >= a[i].x[j][k - 1]) {fl2 = 0; break;}
if(fl1) a[i].taxi++;
else if(fl2) a[i].pizza++;
else a[i].girl++;
}
}
sort(a + 1, a + n + 1, cmp1);
int tmp = a[1].taxi;
sort(a + 1, a + n + 1, cmpid);
printf("If you want to call a taxi, you should call: ");
F(i, 1, n) if(a[i].taxi == tmp) ans1[++cnt] = a[i];
F(i, 1, cnt) cout << ans1[i].name << (i == cnt ? ".\n" : ", ");
sort(a + 1, a + n + 1, cmp2);
printf("If you want to order a pizza, you should call: ");
tmp = a[1].pizza, cnt = 0;
sort(a + 1, a + n + 1, cmpid);
F(i, 1, n) if(a[i].pizza == tmp) ans2[++cnt] = a[i];
F(i, 1, cnt) cout << ans2[i].name << (i == cnt ? ".\n" : ", ");
sort(a + 1, a + n + 1, cmp3);
printf("If you want to go to a cafe with a wonderful girl, you should call: ");
tmp = a[1].girl, cnt = 0;
sort(a + 1, a + n + 1, cmpid);
F(i, 1, n) if(a[i].girl == tmp) ans3[++cnt] = a[i];
F(i, 1, cnt) cout << ans3[i].name << (i == cnt ? ".\n" : ", ");
return 0;
}

CF151B Phone Numbers 题解的更多相关文章

  1. CF55D Beautiful numbers 题解

    题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...

  2. Hdoj 1905.Pseudoprime numbers 题解

    Problem Description Fermat's theorem states that for any prime number p and for any integer a > 1 ...

  3. Hdoj 1058.Humble Numbers 题解

    Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...

  4. [LeetCode] Add Two Numbers题解

    Add Two Numbers: You are given two non-empty linked lists representing two non-negative integers. Th ...

  5. poj 1995 Raising Modulo Numbers 题解

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6347   Accepted: ...

  6. CF1265B Beautiful Numbers 题解

    Content 给定一个 \(1\sim n\) 的排列,请求出对于 \(1\leqslant m\leqslant n\),是否存在一个区间满足这个区间是一个 \(1\sim m\) 的排列. 数据 ...

  7. CF1157A-Reachable Numbers题解

    原题地址 题目大意:有一个函数\(f(x)\),效果是将\(x+1\)后,去掉末尾所有的\(0\),例如: \(f(599)=6\),因为\(599+1=600→60→6\) \(f(7)=8\),因 ...

  8. CF359D:Pair of Numbers——题解

    https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数 ...

  9. Timus : 1002. Phone Numbers 题解

    把电话号码转换成为词典中能够记忆的的单词的组合,找到最短的组合. 我这道题应用到的知识点: 1 Trie数据结构 2 map的应用 3 动态规划法Word Break的知识 4 递归剪枝法 思路: 1 ...

随机推荐

  1. myeclipse maven web打包

    1.在当前的项目pom.xml的文件上,如下图所示:鼠标右键->run As->Maven Build...

  2. html+css第三篇

    css reset 原则: 但凡是浏览默认的样式,都不要使用. body,dl,dd,p,h1,h2,h3,h4,h5,h6{margin:0;font-size:12px;} ol,ul{margi ...

  3. BehaviorTree.CPP.行为树XML格式(六)

    The XML format XML模式的基础 在第一个教程中,介绍了这个简单的树. <root main_tree_to_execute = "MainTree" > ...

  4. R shiny 小工具Windows本地打包部署

    目录 服务器部署简介 windows打包部署 1. 部署基本框架 2.安装shiny脚本需要的依赖包 3.创建运行shiny的程序 [报错解决]无法定位程序输入点EXTPTE_PTR于动态链接库 将小 ...

  5. 安卓手机添加系统证书方法(HTTPS抓包)

    目录 1. 导出证书(以Charles为例) 2. 安卓证书储存格式 3. 将导出的证书计算hash值 4. 生成系统系统预设格式证书文件 5. 上传证书 安卓7.0以后,安卓不信任用户安装的证书,所 ...

  6. Linux升级命令yum upgrade和yum update的区别

    Linux升级命令有两个分别是yum upgrade和yum update, 这个两个命令是有区别的: yum -y update 升级所有包同时也升级软件和系统内核 yum -y upgrade 只 ...

  7. kubernetes部署 etcd 集群

    本文档介绍部署一个三节点高可用 etcd 集群的步骤: etcd 集群各节点的名称和 IP 如下: kube-node0:192.168.111.10kube-node1:192.168.111.11 ...

  8. 【Reverse】每日必逆0x03

    BUU-刮开有奖 附件:https://files.buuoj.cn/files/abe6e2152471e1e1cbd9e5c0cae95d29/8f80610b-8701-4c7f-ad60-63 ...

  9. 如何让Linux 机器CPU使用率变高

    如何让Linux 机器CPU使用率变高 一.实现 1.单行命令搞定 for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" ...

  10. 高效读取大文件,再也不用担心 OOM 了!

    内存读取 第一个版本,采用内存读取的方式,所有的数据首先读读取到内存中,程序代码如下: Stopwatch stopwatch = Stopwatch.createStarted(); // 将全部行 ...