如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。

URAL/1563

来自"NOCOW"

跳转到: 导航, 搜索
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int cmp(const void *x,const void *y)
{
    if(strlen((char*)x)!=strlen((char*)y))
        return(strlen((char*)x)-strlen((char*)y));
    return(strcmp((char*)x,(char*)y));
}
 
char v[1001][256];
 
int main()
{
    int i,n,ans=0;
    scanf("%d",&n);
    gets(v[n]);
    for(i=0;i<n;i++)
        gets(v[i]);
    qsort(v,n,sizeof(char)*256,cmp);
    for(i=0;i<n;i++)
        if(cmp(&v[i],&v[i+1])==0)
            ans+=1;
    printf("%d",ans);
    return 0;
}





VAR
  a:array [1..1000] of string;
  i,j,k,n:longint;
Procedure Qsort(low,high:longint);
VAR
  i,j:longint;
  t,mid:string;
BEGIN
  i:=low;
  j:=high;
  mid:=a[(low+high) div 2];
    repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
        if i<=j then
          BEGIN
            t:=a[i];
            a[i]:=a[j];
            a[j]:=t;
            inc(i);
            dec(j);
          END;
    until i>j;
    if low<j then Qsort(low,j);
    if i<high then Qsort(i,high);
END;
BEGIN
  readln(n);
    for i:=1 to n do readln(a[i]);
  Qsort(1,n);
    for i:=2 to n do
      if a[i]=a[i-1] then inc(k);
  writeln(k);
END.
//from lzoi_ys
个人工具