BestCoder Round #50 (div.2)(hdu 5364,hdu 5365,hdu 5366)

Distribution money

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5364

解题思路:http://blog.csdn.net/piaocoder/article/details/47608121

#include <iostream>  
#include <cstdio>  
#include <algorithm>  
using namespace std;  
int main(){  
    int n;  
    int a[1005];  
    while(~scanf("%d",&n)){  
        for(int i = 0; i < n; i++)  
            scanf("%d",&a[i]);  
        sort(a,a+n);  
        int tmp = a[0];  
        a[n] = n+1;  
        int sum = 0,sumtmp = 1,maxnum = 0;  
        for(int i = 1; i <= n; i++){  
            if(tmp == a[i])  
                sumtmp++;  
            else{  
                if(sum < sumtmp){  
                    maxnum = a[i-1];  
                    sum = sumtmp;  
                }  
                sumtmp = 1;  
                tmp = a[i];  
            }  
        }  
        if(sum > n-sum)  
            printf("%d\n",maxnum);  
        else  
            printf("-1\n");  
    }  
    return 0;  
}  


Run

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5365

解题思路:http://blog.csdn.net/piaocoder/article/details/47608369

#include <iostream>  
#include <cstdio>  
#include <algorithm>  
using namespace std;  
  
int x[25],y[25];  
  
int dis(int x1,int y1,int x2,int y2){  
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);  
}  
  
int main(){  
    int n;  
    while(~scanf("%d",&n)){  
        for(int i = 0; i < n; i++)  
            scanf("%d%d",&x[i],&y[i]);  
        int sum = 0;  
        int d[6];  
        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++){  
                        d[0] = dis(x[i],y[i],x[j],y[j]);  
                        d[1] = dis(x[i],y[i],x[k],y[k]);  
                        d[2] = dis(x[i],y[i],x[l],y[l]);  
                        d[3] = dis(x[j],y[j],x[k],y[k]);  
                        d[4] = dis(x[j],y[j],x[l],y[l]);  
                        d[5] = dis(x[k],y[k],x[l],y[l]);  
                        sort(d,d+6);  
                        if(d[0] == d[1] && d[1] == d[2] && d[2] == d[3] && d[4] == 2*d[0] && d[5] == 2*d[0])  
                            sum++;  
                    }  
        printf("%d\n",sum);  
    }  
    return 0;  
}  


The mook jong

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5366

解题思路:http://blog.csdn.net/piaocoder/article/details/47608809

#include <iostream>  
#include <cstdio>  
using namespace std;  
  
typedef long long ll;  
ll dp[65];  
  
int main(){  
    dp[1] = 1;dp[2] = 2;dp[3] = 3;  
    for(int i = 4; i <= 60; i++)  
        dp[i] = dp[i-3]+1+dp[i-1];  
    int n;  
    while(~scanf("%d",&n))  
        printf("%lld\n",dp[n]);  
    return 0;  
}  



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值