程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Codeforces Beta Round #32

Codeforces Beta Round #32

編輯:C++入門知識

時運不濟,繼續水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;
}

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved