bestcoder#50

bestcoder#50

A题:水题。注意只有一个的情况。

C题:递推水题。f[n]=f[n-1]+f[n-3]+1。

B题:

给定一些整点,判断这些整点组成的正三,四,五,六边形的个数,数据范围很小。

整点只能组成正四边形,因此直接暴力枚举所有的四个点能否组成正方形就行了,然后重复的情况主要出现在四个点的顺序,每个点有顺时针和逆时针,因此最后除以8就行了。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<math.h>
#include<cctype>
#define ll long long
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define REPP(i,a,b,t) for(int (i)=(a);(i)<=(b);(i)+=(t))
#define rep(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define repp(i,a,b,t) for(int (i)=(a);(i)>=(b);(i)-=(t))
#define PII pair<int,int>
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define RS(x) scanf("%s",x)
#define RSS(x,y) scanf("%s%s",x,y)
#define DRS(x) char x[maxn];scanf("%s",x)
#define DRSS(x,y) char x[maxn],y[maxn];scanf("%s%s",x,y)
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)(v).size()

using namespace std;

const int maxn=1000100;
const int INF=(1<<29);
const double EPS=0.0000000001;
const double Pi=acos(-1.0);

struct Point
{
    int x,y;
    friend Point operator-(Point A,Point B)
    {
        Point res;
        res.x=A.x-B.x;
        res.y=A.y-B.y;
        return res;
    }
    friend int operator*(Point A,Point B)///点乘
    {
        return A.x*B.x+A.y*B.y;
    }
};
int n;
Point p[maxn];

int dist(Point A,Point B)
{
    int tx=A.x-B.x,ty=A.y-B.y;
    return tx*tx+ty*ty;
}

bool judge(Point A,Point B,Point C,Point D)
{
    if((B-A)*(C-B)==0&&(C-B)*(D-C)==0&&(D-C)*(A-D)==0&&(A-D)*(B-A)==0){
        int d1=dist(A,B);
        int d2=dist(B,C);
        int d3=dist(C,D);
        int d4=dist(D,A);
        if(d1==d2&&d2==d3&&d3==d4&&d4==d1) return 1;
    }
    return 0;
}

int main()
{
    freopen("in.txt","r",stdin);
    while(~RI(n)){
        REP(i,1,n) RII(p[i].x,p[i].y);
        ll ans=0;
        REP(i,1,n){
            REP(j,1,n){
                if(j==i) continue;
                REP(k,1,n){
                    if(k==j||k==i) continue;
                    REP(q,1,n){
                        if(q==k||q==j||q==i) continue;
                        if(judge(p[i],p[j],p[k],p[q])){
                            ans++;
                        }
                    }
                }
            }
        }
        cout<<ans/8<<endl;
    }
    return 0;
}

D题:线段树。。待补充。。。。。

看来这段时间在刷专题的同时得抽出时间每天打cf了。。不然碰到思维题又死机了。。。。

时间: 2024-10-16 15:18:15

bestcoder#50的相关文章

BestCoder Round #50 (div.2)

题目传送:BestCoder Round #50 (div.2) BC感觉越做越无语了 1001.Distribution money AC代码: #include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <queue> #include <stack> #include <bitset> #

DP BestCoder Round #50 (div.2) 1003 The mook jong

题目传送门 1 /* 2 DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: 3 dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp[i][0] = dp[i-1][1] + dp[i-1][0]; 4 比赛时二维dp写搓了,主要是边界情况的判断出错,比如dp[3][1] = 1,因为第3块放了木桩,其他地方不能再放,dp[3][0]同理 5 解释一下dp[i][1]的三种情况,可能是前面相隔2个放的方案或者是不放的

计算几何(水)BestCoder Round #50 (div.2) 1002 Run

题目传送门 1 /* 2 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 3 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-8 19:54:14 8 * File Name :B.cpp 9 ************

BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)

题目:Click here 题意:bestcoder上面有中文题目 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <string> 7 #include <climits> 8 #include <vector> 9 #incl

BestCoder Round #50 (div.2) HDU 5365 Run(简单几何)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5365 题面:(严重吐槽,看着真不舒服,还是改一下吧) Run Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 549    Accepted Submission(s): 245 Problem Description AFA is a g

BestCoder Round #50 (div.1) 1002 Run (HDU OJ 5365) 暴力枚举+正多边形判定

题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #define power(x) ((x)*(x))

【BestCoder】【Round#42】

模拟+链表+DP Orz AK爷faebdc A Growin要跟全部的n个人握手共2n杯香槟,再加上每对关系的两杯香槟,直接统计邻接矩阵中1的个数,再加2n就是answer 1 //BestCoder 42 A 2 #include<vector> 3 #include<cstdio> 4 #include<cstring> 5 #include<cstdlib> 6 #include<iostream> 7 #include<algor

BestCoder Round #11 (Div. 2) 题解

HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 302    Accepted Submission(s): 229 Problem Description Bob and Alice got separated in the Square, they agreed that if they

hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7    Accepted Submission(s): 4 Problem Description Hanamichi is taking part in