这题就是字符串处理
Program P1002;
Type
phone=record
num,s:longint;
end;
var
n,i,j,p:Longint;
b:boolean;
s:ansistring;
a:array[0..9999999] of longint;
// f:array[1..100000] of phone;
ch:array['A'..'Z'] of longint=(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,-1,7,7,8,8,8,9,9,9,-1);
function isdight(c:char):longint;
var
i,j,p:longint;
begin
p:=ord(c);
if (48<=p) and (p<58) then exit(p-48);
if (65<=p) and (p<=90) then
begin
if ch[c]<>-1 then exit(ch[c]);
end;
exit(-1);
end;
function hash:longint;
var
i,j,p:longint;
begin
j:=0;
hash:=0;
for i:=1 to length(s) do
begin
if s[i]='-' then continue;
p:=isdight(s[i]);
if (p=-1) or ((p<>-1) and (j=7)) then exit(-1);
hash:=hash*10+p;
inc(j);
end;
if j<>7 then exit(-1);
end;
procedure pri(p:longint);
var
i,j:longint;
begin
b:=true;
i:=p div 10000;
j:=p mod 10000;
if i<100 then write('0');
if i<10 then write('0');
write(i,'-');
if j<1000 then write('0');
if j<100 then write('0');
if j<10 then write('0');
writeln(j,' ',a[p]);
end;
Begin
b:=false;
readln(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do
begin
readln(s);
p:=hash;
if p=-1 then continue
else inc(a[p]);
end;
for i:=0 to 9999999 do
if a[i]>1 then pri(i);
if not(b) then writeln('No duplicates.');
End.
分享到:
相关推荐
poj1002 的源代码 第一次做 超时了
使用vs2010的project,代码是poj1002,北京大学在线测试系统
北大POJ1016-Numbers That Count【字符串处理】 解题报告+AC代码
poj1002 source code input: The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on ...
经过编辑通过 POJ1002 C++编程
业余爱好。所以,算法不一定好,CODING也不一定佳,效率不一定高,只是能通过online judge而已。
北大POJ1002-487-3279【Hash+Qsort】 解题报告+AC代码
这是北大在线测试的第1002题,方便记忆的电话号码的解题例程,题目中有一个列表,记录着许多方便记忆的电话号码。不同的方便记忆的电话号码可能对应相同的标准号码,这个程序的任务就是找到它们
East Central North America 1999。50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50字50...
poj-1002源码,没有题解,题解看博客poj-1002源码,没有题解,题解看博客poj-1002源码,没有题解,题解看博客poj-1002源码,没有题解,题解看博客
Q和Z没有映射到任何数字,连字符不需要拨号,可以任意添加和删除。 TUT-GLOP的标准格式是888-4567,310-GINO的标准格式是310-4466,3-10-10-10的标准格式是310-1010。 如果两个号码有相同的标准格式,那么他们就是...
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 phrase. For example, you can call the University ...
LeetCode判断字符串是否循环 :bookmark_tabs:Plan 动态规划 背包问题 动态规划 POJ 3267 POJ 1260 POJ 1015 POJ 3176 POJ 1080 POJ 1159 POJ 2533 POJ 1836 Leetcode 70 Leetcode 309 搜索 DFS POJ 2488 POJ 3083 ...
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
如题所示,亲测可用。电话号码查重,不会的同学可以参考下,会做的同学可以给挑挑毛病!大家以代码会友!
上面可能有poj的题目,hdu的题目,spoj的题目,sgu的题目,hust上的题目,fzu上的题目
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
POJ北大在线测评系统离线题库,里面包含1002-3422题,可以离线刷题。
在进行ACM编程训练时做字符串专题的一些题目(POJ1782,POJ1790,POJ1951,POJ2003,POJ2121)