Mar 15

百度杯 华中北区程序设计邀请赛 预赛 不指定

felix021 @ 2009-3-15 00:14 [IT » 程序设计] 评论(4) , 引用(0) , 阅读(6379) | Via 本站原创 | |
BFS @ 2009-03-14
A,搜索,没做。
B,搜索,没做。
C,计算几何,没做。
D,加密算法,Boluor没做完。
E,模拟,Sandy写的,trick是需要先判断下一个走的人是谁(B/W)。
F,表达式的计算,我之前没有看题目,但是扫了一下,觉得应该很简单,回头写一下,应该不难吧。
G,计算几何,超简单的一个等比方程解一下;trick在于两个int加起来以后会OverFlow。
H,字符串处理,数据量很小,不要Trie,用map+set搞定。
I,没看。
J,DP,Sandy推出一个方程,和他讨论了一下,就被拖到机房去,然后他写了AC了。

oak真是相当的不堪阿,sigh。

--

党员活动室确实很适合看电影,音效非常好。

--

贴上我写的代码:

//G - Pinhole Image
#include<stdio.h>
#include<math.h>

int main(){
    int n, A, B, H;
    scanf("%d", &n);
    while (n--){
        scanf("%d%d%d", &A, &B, &H);
        printf("%.2lf\n",(double)B * (double)H / (double)A);
    }
    return 0;
}

//H - URL
#include<iostream>
#include<cstring>
#include<map>
#include<set>
using namespace std;

struct ooxx{
    string t;
    int c;
    friend inline bool operator <(const ooxx &a, const ooxx &b){
        return ((a.c > b.c) ||
                (a.c == b.c && a.t < b.t));
    }
};

char act[20], url[110];
map<string, int>st;
map<string, int>::iterator p, q;
set<ooxx> jiong;
set<ooxx>::iterator jp;

void visit();
void display();

int main(){
    int T, N;
    scanf("%d", &T);
    while(T--){
        st.clear();
        scanf("%d", &N);
        for (int i = 0; i < N; ++i){
            scanf("%s%s", act, url);
            if(act[0] == 'V') visit();
            else display();
        }
    }
    return 0;
}

void visit(){
    string t = string(url);
    st[t]++;
}

void display(){
    jiong.clear();
    int len = strlen(url), i;
    for(p = st.begin(), q = st.end(); p != q; p++){
        for(i = 0; i < len; ++i){
            if(p->first[i] != url[i]) break;
        }
        if(i == len){
            ooxx a;
            a.t = p->first;
            a.c = p->second;
            jiong.insert(a);
        }
    }
    for(jp = jiong.begin(); jp != jiong.end(); jp++){
        printf("%s\n", (jp->t).c_str());
    }
    printf("\n");
}




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
Luoxi029
2009-3-17 22:44
膜拜
felix021 回复于 2009-3-17 23:45
- -||
snoopy
2009-3-16 17:44
汗, 就算要 ooxx 命名变量, 也不用这么长吧
话说, 原来中山流传的是, 变量名用 mm, ppmm, gf 之类的会有意外爆击 :P
felix021 回复于 2009-3-16 20:03
ooxx打顺手了。。。
LiuYu Homepage
2009-3-16 08:56
这么多题呀..

我看见ooxx了..
felix021 回复于 2009-3-16 11:10
嗯,不想起名,所以顺手写了ooxx, 还有jiong, jp....
Xplus Email Homepage
2009-3-15 00:29
天天看电影吧。。
felix021 回复于 2009-3-15 02:55
...没那么多时间。。。
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]