Codeforces Beta Round #32

acm_cxlove發表於2013-08-18

轉載請註明出處,謝謝http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove

時運不濟,繼續水CF。。。

A:Reconnaissance

列舉


B:Borze

模擬


C:Flea

先算出最多可以多少個,然後 統計一下有多少個位置

LL n , m , s;
int main () {
    #ifndef ONLINE_JUDGE
        freopen ("input.txt" , "r" , stdin);
        // freopen ("output.txt" , "w" , stdout);
    #endif
    cin >> n  >> m >> s;
    LL w = (n - 1) / s;
    LL h = (m - 1) / s;
    LL cnt = (w + 1) * (h + 1);
    LL a = min (s - 1 , (m - 1) % s);
    LL b = min (s - 1 , (n - 1) % s);
    cout << (a + 1) * (b + 1) * cnt << endl;
    return 0;
}

D:Constellation

列舉每個位置,列舉半徑,然後排序,輸出。。


E:Hide and seek

簡單幾何

首先判斷能否直接看到目標,判斷條件是不和牆相交 且 (不和鏡子相交或者和鏡子平行)

然後再判斷能否反射看到,做目標點關於鏡子的反射點,然後連線源點和反射點,判斷與鏡子是否有交點,否則不可達。

然後再判斷下入射光線和反射光線是否會和牆相交。

const double eps = 1e-8;
int dcmp (double d) {
    return d < -eps ? -1 : d > eps;
}
struct Point {
    double x , y;
    Point () {}
    Point (double _x , double _y):x(_x),y(_y){}
    void input () {
        scanf ("%lf %lf" , &x , &y);
    }
    inline Point operator - (const Point &p) const {
        return Point (x - p.x , y - p.y);
    }
    inline Point operator + (const Point &p) const {
        return Point (x + p.x , y + p.y);
    }
    inline double operator * (const Point &p) const {
        return x * p.y - y * p.x;
    }
    inline double operator / (const Point &p) const {
        return x * p.x + y * p.y;
    }
    inline Point operator * (const double d) const {
        return Point (x * d , y * d);
    }
    inline Point operator / (const double d) const {
        return Point (x / d , y / d);
    }
    inline Point turnLeft () {
        return Point (-y , x);
    }
}s , e;
struct Line {
    Point a , b;
    Line () {}
    Line (Point _a , Point _b):a(_a),b(_b){}
    void input () {
        a.input ();
        b.input ();
    }
    inline double operator * (const Point &p) const {
        return (b - a) * (p - a);
    }
    inline double operator / (const Point &p) const {
        return (p - a) / (p - b);
    }
    inline int SegCrossSeg (const Line &v) {
        int d1 = dcmp ((*this) * v.a);
        int d2 = dcmp ((*this) * v.b);
        int d3 = dcmp (v * a);
        int d4 = dcmp (v * b);
        if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;
        return ((d1 == 0 && dcmp ((*this) / v.a) <= 0)
            || (d2 == 0 && dcmp ((*this) / v.b) <= 0)
            || (d3 == 0 && dcmp (v / a) <= 0)
                || (d4 == 0 && dcmp (v / b) <= 0));
    }
    inline bool parallel (Line v) {
        return !dcmp ((b - a) * (v.b - v.a));
    }
    inline Point CrossPoint (const Line &v) {
        double s1 = v * a , s2 = v * b;
        return (a * s2 - b * s1) / (s2 - s1);
    }
    inline Point PointToLine (const Point &p) {
        return CrossPoint (Line (p , p + (a - b).turnLeft ()));
    }
    inline Point SymPoint (const Point &p) {
        return PointToLine (p) * 2 - p;
    }
}wall , mirror;
int main () {
    #ifndef ONLINE_JUDGE
        freopen ("input.txt" , "r" , stdin);
        // freopen ("output.txt" , "w" , stdout);
    #endif
    s.input ();e.input ();
    wall.input ();mirror.input ();
    if (wall.SegCrossSeg (Line (s , e)) == 0 ) {
        if (mirror.SegCrossSeg (Line (s , e)) == 0 || mirror.parallel (Line (s , e))) {
            puts ("YES");
            return 0;
        }
    }
    Point t = mirror.SymPoint (e);
    if (mirror.SegCrossSeg (Line (s , t)) >= 1) {
        Point p = mirror.CrossPoint (Line (s , t));
        if (wall.SegCrossSeg (Line (s , p)) == 0 && wall.SegCrossSeg (Line (p , e)) == 0) {
            puts ("YES");
            return 0;
        }
    }
    puts ("NO");
    return 0;
}







相關文章