371 条题解

  • 0
    @ 2014-01-31 17:37:45

    #include<iostream>
    #include<algorithm>
    using namespace std;
    int a[100];
    int main()
    {
    int n; cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n); int ans=unique(a,a+n)-a;
    cout<<ans<<endl;
    for(int i=0;i<ans;i++) cout<<a[i]<<" ";
    }
    论stl的重要性。。。

  • 0
    @ 2014-01-18 14:37:22

    var
    num,sum,i,j,temp :longint;
    ran:array[1..100] of integer;

    begin
    readln (num);
    for i:=1 to num do read(ran[i]);
    for i:=1 to num do
    for j:=1 to num do
    begin
    if i<>j then
    begin
    if ran[i]=ran[j] then ran[j]:=0
    end;
    end;

    for i:=1 to num do
    begin
    if ran[i]<>0 then sum:=sum+1;
    end;

    for i:=1 to num do
    for j:=i to num do
    begin
    if ran[i]>ran[j] then
    begin
    temp:=ran[i];
    ran[i]:=ran[j];
    ran[j]:=temp;
    end;
    end;

    writeln;
    writeln (sum);
    for i:=1 to num do
    begin
    if ran[i]<>0 then write(ran[i],' ');
    end;
    writeln;
    end.

  • 0
    @ 2014-01-01 12:01:07

    Vijos 题解:http://hi.baidu.com/umule/item/2c997f8ed9600fdae596e017
    有疑问请留言 共同进步

  • 0
    @ 2013-11-27 13:09:46

    测试数据 #0: Accepted, time = 0 ms, mem = 440 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 452 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 444 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 444 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 448 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 440 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 448 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 448 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 452 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 448 KiB, score = 10
    不足之处欢迎大家指教
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    bool b[1001];int i,n,a[101],len=0,c;
    main(){
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&c);if(!b[c]){a[++len]=c;b[c]=1;} }
    sort(a+1,a+1+len);
    printf("%d\n",len);
    for(i=1;i<len;i++)printf("%d ",a[i]);
    printf("%d\n",a[len]);
    }

  • 0
    @ 2013-11-14 12:30:13

    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 568 KiB, score = 10
    测试数据 #1: Accepted, time = 15 ms, mem = 568 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    测试数据 #3: Accepted, time = 15 ms, mem = 568 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 568 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 568 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 564 KiB, score = 10
    Accepted, time = 75 ms, mem = 568 KiB, score = 100
    代码
    #include<iostream>
    #include<cstdio>
    using namespace std;

    int a[1001]={0};

    int main(){
    int n,i,x,s=0,j;
    cin>>n;
    for(i=1;i<=n;i++){
    cin>>x;
    a[x]=1;
    }
    for(i=1;i<=1000;i++){
    s=s+a[i];
    }
    cout<<s<<endl;
    j=1000;
    while(a[j]==0)j--;
    for(i=1;i<=j-1;i++){
    if(a[i]==1)cout<<i<<' ';
    }
    cout<<j<<endl;
    }

  • 0
    @ 2013-11-03 12:32:14

    堪称最简
    var a,b:array[1..2000] of longint; n,i,num,k:longint;
    begin
    readln(n);
    for i:=1 to n do
    begin
    begin
    read(k); b[i]:=k;
    a[k]:=a[k]+1;
    end;
    end;
    for i:=1 to 2000 do if a[i]<>0 then num:=num+1; writeln(num);
    for i:=1 to 2000 do if a[i]>0 then write(i,' ');
    end.
    满分

    • @ 2013-11-06 13:43:15

      水,用标记。。
      附上代码
      var i,j,num,total:integer;
      n:array[1..1000] of boolean;
      begin
      fillchar(n,sizeof(n),false);
      readln(num);
      total:=0;
      for i:=1 to num do begin
      read(j);
      if not n[j] then begin n[j]:=true;inc(total);end;
      end;
      writeln(total);
      for i:=1 to 1000 do if n[i] then write(i,' ');
      end.

    • @ 2013-11-06 13:46:14

      测试数据 #0: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #1: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #2: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #3: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #4: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #6: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #7: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #8: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #9: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      Accepted, time = 0 ms, mem = 824 KiB, score = 100

    • @ 2013-11-06 13:46:21

      测试数据 #0: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #1: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #2: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #3: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #4: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #6: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #7: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #8: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #9: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      Accepted, time = 0 ms, mem = 824 KiB, score = 100

    • @ 2013-11-06 13:46:32

      测试数据 #0: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #1: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #2: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #3: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #4: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #6: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #7: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #8: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #9: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      Accepted, time = 0 ms, mem = 824 KiB, score = 100

    • @ 2013-11-06 13:46:43

      测试数据 #0: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #1: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #2: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #3: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #4: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #6: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #7: Accepted, time = 0 ms, mem = 824 KiB, score = 10

      测试数据 #8: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      测试数据 #9: Accepted, time = 0 ms, mem = 820 KiB, score = 10

      Accepted, time = 0 ms, mem = 824 KiB, score = 100

  • 0
    @ 2013-11-03 12:31:27

    编译成功

    foo.pas(9,13) Warning: Variable "a" does not seem to be initialized
    foo.pas(12,42) Warning: Variable "num" does not seem to be initialized
    测试数据 #0: Accepted, time = 0 ms, mem = 836 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 840 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 836 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 840 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 840 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 836 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 836 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 836 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 840 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 840 KiB, score = 10
    Accepted, time = 0 ms, mem = 840 KiB, score = 100
    代码
    var a,b:array[1..2000] of longint; n,i,num,k:longint;

    begin
    readln(n);
    for i:=1 to n do
    begin
    begin
    read(k); b[i]:=k;
    a[k]:=a[k]+1;
    end;
    end;
    for i:=1 to 2000 do if a[i]<>0 then num:=num+1; writeln(num);

    for i:=1 to 2000 do if a[i]>0 then write(i,' ');
    end.

  • 0
    @ 2013-10-27 18:52:56

    var
    a, b: array[1..1000] of longint;
    n, i, j, t: longint;
    begin
    readln(n);
    for i := 1 to n do
    Read(a[i]);
    readln;
    for i := 1 to n - 1 do
    for j := 1 to n - i do
    if a[j] > a[j + 1] then
    begin
    t := a[j];
    a[j] := a[j + 1];
    a[j + 1] := t;
    end;
    for i := 1 to n - 1 do
    if a[i] = a[i + 1] then
    a[i] := maxlongint;
    t := 0;
    for i := 1 to n do
    if a[i] <> maxlongint then
    t := t + 1;
    writeln(t);
    j := 1;
    for i := 1 to n do
    if a[i] <> maxlongint then
    begin
    b[j] := a[i];
    Inc(j);
    end;
    for i := 1 to j - 2 do
    Write(b[i], ' ');
    writeln(b[j - 1]);
    end.

  • 0
    @ 2013-10-23 17:54:01

    基数排序
    var
    a:array[1..1000]of integer;
    i,j,n,x,total:integer;
    begin
    readln(n);
    for i:=1 to n do
    begin
    read(x);
    inc(a[x]);
    end;
    for i:=1 to 1000 do
    if a[i]<>0 then
    inc(total);
    writeln(total);
    for i:=1 to 1000 do
    if a[i]<>0 then write(i,' ');
    end.

  • 0
    @ 2013-10-06 07:56:02

    var n,i,j,x:longint;
    a,ed:array[0..101] of longint;
    s:array[-1000..1000] of longint;

    begin
    readln(n);
    fillchar(s,sizeof(s),0);
    for i:=1 to n do read(a[i]);
    x:=n;
    for i:=1 to n do
    inc(s[a[i]]);
    j:=1;
    for i:=-1000 to 1000 do if s[i]<>0 then begin
    ed[j]:=i;inc(j); end;
    writeln(j-1);
    for i:=1 to j-1
    do write(ed[i],' ');
    writeln(chr(8)) ;

    end.

  • 0
    @ 2013-08-12 09:05:33

    Var a:array[0..1000] of longint;
    n,i,num:longint;
    Procedure qsort(l,r:longint);
    Var i,j,x,y:longint;
    Begin
    i:=l; j:=r;
    x:=a[(l+r) shr 1];
    Repeat
    while x>a[i] do inc(i);
    while x<a[j] do dec(j);
    if i<=j then
    begin
    y:=a[i];
    a[i]:=a[j];
    a[j]:=y;
    inc(i); dec(j);
    end;
    Until i>j;
    If i<r then qsort(i,r);
    If j>l then qsort(l,j);
    End;
    Begin
    Readln(n);
    For i:=1 to n do read(a[i]);
    qsort(1,n);
    For i:=1 to n do
    If a[i]<>a[i-1] then
    inc(num);
    writeln(num);
    For i:=1 to n do
    If a[i]<>a[i-1] then
    write(a[i],' ');
    readln;
    End.

  • 0
    @ 2013-05-29 20:28:40

    用STL是个不错的选择。。。。(误
    #include <iostream>
    #include <set>
    using namespace std;

    set<int> randoms;

    int main()
    {
    int n, ra;
    cin>>n;
    while(n--) {
    cin>>ra;
    randoms.insert(ra);
    }
    cout<<randoms.size()<<endl;
    for(set<int>::iterator i=randoms.begin();
    i!=randoms.end();i++) {
    cout<<*i<<' ';
    }
    return 0;
    }

  • 0
    @ 2013-04-14 19:57:39

    const
    max=1000000;
    var a:array[1..max]of integer;
    i,j,k,m,n:integer;
    begin
    readln(n);
    for i:=1 to n do
    read(a[i]);
    for i:=1 to n-1 do
    begin
    for j:=i+1 to n do
    if a[i]>=a[j] then
    begin
    k:=a[i]; a[i]:=a[j]; a[j]:=k;
    end;
    end;
    for i:=1 to n-1 do
    for j:=i+1 to n do
    begin
    if a[i]=a[j] then
    begin
    a[i]:=0;
    inc(m);
    end;
    end;
    writeln(n-m);
    for i:=1 to n do
    if a[i]<>0 then
    write(a[i],' ');
    readln;
    readln
    end.

  • 0
    @ 2013-04-14 19:57:00

    测试数据 #0: Accepted, time = 15 ms, mem = 2680 KiB, score = 10
    测试数据 #1: Accepted, time = 23 ms, mem = 2684 KiB, score = 10
    测试数据 #2: Accepted, time = 7 ms, mem = 2684 KiB, score = 10
    测试数据 #3: Accepted, time = 11 ms, mem = 2680 KiB, score = 10
    测试数据 #4: Accepted, time = 23 ms, mem = 2684 KiB, score = 10
    测试数据 #5: Accepted, time = 11 ms, mem = 2684 KiB, score = 10
    测试数据 #6: Accepted, time = 23 ms, mem = 2684 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 2680 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 2684 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 2684 KiB, score = 10
    Summary: Accepted, time = 158 ms, mem = 2684 KiB, score = 100

  • 0
    @ 2013-04-12 22:09:06

    var

    a,b:array [1..1001] of integer;

    i,j,k,l,m,n:longint;

    begin

    readln(n);

    for i:=1 to n do

    read(a[i]);

    for i:=1 to n-1 do

    for k:=i+1 to n do

    if a[i]>a[k] then

    begin

    l:=a[i];

    a[i]:=a[k];

    a[k]:=l;

    end;

    j:=1;b[1]:=a[1];

    for k:=2 to n do

    if a[k]<>b[j] then begin j:=j+1;b[j]:=a[k]end;

    writeln(j);

    for k:=1 to j do

    write(b[k],' ');

    writeln;

    end.

  • 0
    @ 2012-11-09 09:57:09

    明日NOIP决赛,见一水题,刷之以应!

    点这里查看程序源码+详细题解

  • 0
    @ 2012-10-10 20:55:20

    jian dan de pai xu ti

  • 0
    @ 2012-08-14 18:22:06

    AVL tree 不错的选择...

  • 0
    @ 2012-08-06 00:38:21

    #01: Accepted (418ms, 584KB)

    #02: Accepted (430ms, 584KB)

    #03: Accepted (160ms, 584KB)

    #04: Accepted (160ms, 584KB)

    #05: Accepted (153ms, 584KB)

    #06: Accepted (149ms, 584KB)

    #07: Accepted (145ms, 584KB)

    #08: Accepted (145ms, 584KB)

    #09: Accepted (164ms, 584KB)

    #10: Accepted (164ms, 584KB)

    Accepted / 100 / 2093ms / 584KB

    var i,j,n,m,s:integer;

    a:array[1..1001] of integer;

    begin

    readln(n);

    fillchar(a,sizeof(a),0);

    for i:=1 to n do

    begin

    read(j);

    inc(a[j]);

    end;

    m:=0;

    for i:=1 to 1001 do if a[i]>0 then inc(m);

    writeln(m);

    s:=0;

    for i:=1 to 1001 do

    begin

    if a[i]>0 thena

    begin

    inc(s);

    if sm then write(i,' ')

    else if s=m then begin writeln(i);break;end;

    end;

    end;

    end.

    洪水

  • 0
    @ 2010-04-01 21:03:30

    var a:array[1..1000] of word;

    i,n,c,t:integer;

    begin

    readln(n);t:=0;fillchar(a,sizeof(a),0);

    for i:=1 to n do begin read(c);if a[c]=0 then inc(t);a[c]:=1;end;

    writeln(t);

    for i:=1 to 1000 do if a[i]0 then begin write(i);break;end;

    for n:=i+1 to 1000 do if a[n]0 then write(' ',n);

    end.

    绝对水

信息

ID
1316
难度
3
分类
其他 | 排序 点击显示
标签
递交数
9960
已通过
4873
通过率
49%
被复制
33
上传者