题解

63 条题解

  • 0
    @ 2013-08-13 12:19:54

    var n,m,i,h,t,temp,num:longint;
    q:array[1..100000] of longint;
    function find(x:longint):boolean;
    var i:longint;
    begin
    for i:=h to t do
    if q[i]=x then exit(true);
    exit(false);
    end;
    procedure add(x:longint);
    begin
    if t-h+1=m then
    inc(h);
    inc(t);
    q[t]:=x;
    end;
    begin
    h:=1;
    t:=0;
    num:=0;
    readln(m,n);
    for i:=1 to n do
    begin
    read(temp);
    if not(find(temp)) then
    begin
    inc(num);
    add(temp);
    end;
    end;
    writeln(num);
    end.

  • 0
    @ 2013-08-07 11:40:55

    O(∩_∩)O~ 一次AC 刷水题最舒服了
    Var n,m,head,tail,i,j,ans,x:longint;
    a,q:array[1..1000000] of longint;
    Begin
    head:=1;
    Readln(m,n);
    For i:=1 to n do
    Begin
    read(x);
    If (a[x]=0) and (tail-head+1<m) then
    begin
    inc(ans);
    inc(tail);
    q[tail]:=x;
    inc(a[x]);
    End;
    If (a[x]=0) and (tail-head+1>=m) then
    begin
    a[q[head]]:=0;
    inc(head);
    inc(ans);
    inc(tail);
    q[tail]:=x;
    inc(a[x]);
    End;
    End;
    Writeln(ans);
    End.

  • 0
    @ 2013-07-25 15:44:34

    include <stdio.h>

    include <stdlib.h>

    include <string.h>

    int main()
    {
    int m, n, i, j, k, flag, flag2, sum;
    k = sum =0;
    int s[1001],h[1001];

    scanf("%d%d", &m, &n);
    memset(s,0,sizeof(s));

    for (i=0;i<n;i++)
    {
    flag= flag2 = 0;
    scanf("%d", &s[i]);
    for (j=0;j<m;j++)
    {
    if(s[i]==h[j])
    {
    flag=1;
    }

    }
    if(flag)
    continue;
    for (j=0;j<m;j++)
    {
    if(k==m)
    {
    h[j] = h[(j+1)];
    flag2 = 1;
    }
    else
    break;
    }
    if(flag2)
    h[m-1]=s[i];
    else
    {
    h[k]=s[i];
    k++;
    }
    sum++;
    }
    printf("%d\n", sum);
    return 0;
    }

信息

ID
1774
难度
4
分类
模拟 点击显示
标签
递交数
3064
已通过
1231
通过率
40%
被复制
10
上传者