请高手传授几招!!!

请高手传授几招,这道题该怎样做???

3 条评论

  • @ 2013-11-05 14:23:06

    #include <cstdio>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    using namespace std;

    int f[20], a[200] = {0}, L, S, T, M , i, j, p, c, ans = 10000, now, tot;

    int main(){
    cin >> L >> S >> T >> M;
    for (i = 0; i < M; ++ i) {
    cin >> a[i];
    }

    if (S == T) {
    ans = 0;
    for (i = 0; i < M; ++ i) {
    if (a[i] % T == 0) {
    ans ++;
    }
    }

    cout << ans;
    return 0;
    }

    sort(a, a + M - 1);
    memset(f, 0x7F, sizeof(f));
    f[0] = 0; now = 0; tot = 0;

    for (i = 1; i < L + T; ++ i) {
    for (j = S; j <= T; ++ j) {
    f[i % T] = min(f[i % T], f[ (i - j + T) % T ]);
    }

    if (a[p] == i) {
    f[i % T] ++;
    p ++;
    }

    if(now == f[i % T]) {
    tot ++; //Öظ´n ´Î£¨ÎÞʯ×Ó£©
    } else {
    now = f[i % T];
    tot = 0;
    }

    if (tot == T){
    i = a[p] - T;
    }
    }
    for (i=0;i < T;i++) {
    ans = min(ans, f[i]);
    }
    cout << ans;
    }

  • @ 2013-10-05 17:41:27

    const
    ac:array[1..7]of longint=(17,19,23,29,31,37,39);
    var
    s,ss,sss:string;
    num:array[0..51]of longint;
    f,fh:array[0..51]of char;
    c,n,cc,ans,ok,z:longint; bool:boolean;

    procedure prep;
    var i:longint;
    begin
    for i:=1 to 51 do num[i]:=0;
    while pos(' ',s)<>0 do delete(s,pos(' ',s),1);
    i:=1;
    while i<=length(s) do
    begin
    if (s[i] in ['+','-'])and((i=1)or(s[i-1]='('))
    then insert('0',s,i);
    inc(i);
    end;
    s:=s+'@';
    ans:=0;
    end;

    function good(a,b:char):boolean;
    begin
    if a in ['@','('] then exit(false);
    if b='@' then exit(true);
    if a='^' then exit(true);
    if b='^' then exit(false);
    if a='*' then
    begin
    if b in['+','-','*',')'] then exit(true);
    exit(false);
    end;
    if a in ['+','-'] then
    begin
    if b in ['*','('] then exit(false);
    exit(true);
    end;
    end;

    function count(a,b:int64; ch:char):int64;
    var p:int64; j:longint;
    begin
    if ch='+' then exit((a+b)mod 97777);
    if ch='-' then
    if a-b<0 then exit((a-b+97777) mod 97777) else exit(a-b);
    if ch='*' then exit((a*b)mod 97777);
    p:=1;
    if ch='^' then
    for j:=1 to b do p:=(p*a)mod 97777;
    exit(p);
    end;

    procedure main;
    var
    i,nt,ft,gc,t:int64;
    begin
    nt:=0;
    ft:=1;
    f[ft]:='@';
    i:=1;
    while (i<=length(s))and(ft<>0) do
    begin
    if s[i] in ['+','-','*','(',')','@','^'] then
    begin
    repeat
    if ((s[i]='@')and(f[ft]='@'))or((s[i]=')')and(f[ft]='(' )) then
    begin
    dec(ft);
    break;
    end;
    if good(f[ft],s[i]) then
    begin
    num[nt-1]:=count(num[nt-1],num[nt],f[ft]);
    dec(ft);
    dec(nt);
    end else
    begin
    inc(ft);
    f[ft]:=s[i];
    break;
    end;
    until false;
    inc(i);
    end else
    begin
    gc:=0;
    repeat
    if s[i] in ['+','-','*','(',')','@','^'] then break;
    if s[i]='a' then gc:=ac[cc] else
    begin
    val(s[i],t);
    gc:=gc*10+t;
    end;
    inc(i);
    until false;
    inc(nt);
    num[nt]:=gc mod 97777;
    end;
    end;
    ans:=num[1];
    end;

    begin
    readln(s);
    readln(n);
    for c:=1 to n do
    begin
    readln(ss);
    bool:=true;
    for cc:=1 to 7 do
    begin
    prep;
    main;
    ok:=ans;
    sss:=s;
    s:=ss;
    prep;
    main;
    if ans<>ok then bool:=false;
    s:=sss;
    end;
    if bool then
    begin
    inc(z);
    fh[z]:=chr(c+64);
    end;
    end;
    for c:=1 to z do write(fh[c]);
    writeln;
    end.

  • @ 2013-03-26 17:02:56

    把A用数带进去= = -_-

  • 1

信息

ID
1003
难度
7
分类
字符串 点击显示
标签
递交数
7413
已通过
1550
通过率
21%
被复制
50
上传者