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>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;

int a[10005];

int main() {
    int n;
    while(scanf("%d", &n) != EOF) {
        memset(a, 0, sizeof(a));
        for(int i = 0; i < n; i ++) {
            int t;
            scanf("%d", &t);
            a[t] ++;
        }
        int ans = -1;
        for(int i = 0; i < 10005; i ++) {
            if(a[i] > n - a[i]) {
                ans = i;    
            }
        }
        if(ans != -1)printf("%d\n", ans);
        else printf("-1\n");
    }
    return 0;
}



1002、Run

AC代码:

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;

struct node {
    int x, y;
}a[55];

int n;

int fun(node a, node b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}

int main() {
    while(scanf("%d", &n) != EOF) {
        for(int i = 0; i < n; i ++) {
            scanf("%d %d", &a[i].x, &a[i].y);
        }

        int ans = 0;
        for(int i = 0; i < n; i ++) {
            for(int j = i + 1; j < n; j ++) {
                for(int k = j + 1; k < n; k ++) {
                    for(int l = k + 1; l < n; l ++) {
                        int x[6];
                        x[0] = fun(a[i], a[j]);
                        x[1] = fun(a[j], a[k]);
                        x[2] = fun(a[k], a[l]);
                        x[3] = fun(a[l], a[i]);
                        x[4] = fun(a[i], a[k]);
                        x[5] = fun(a[j], a[l]);
                        sort(x, x + 6);
                        if((x[0] == x[1]) && (x[0] == x[2]) && (x[0] == x[3]) && (x[4] == x[5])) {
                            ans ++;
                        }
                    }
                }
            }
        }
        printf("%d\n", ans);

    }
    return 0;
}



1003、The mook jong

AC代码:

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#define LL long long
#define INF 0x7fffffff
using namespace std;

LL dp[105];

int n;

int main() {
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 3;
    for(int i = 4; i < 65; i ++) {
        dp[i] = dp[i - 1] + dp[i - 3] + 1; 
    }
    while(scanf("%d", &n) != EOF) {
        printf("%I64d\n", dp[n]);
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值