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

1.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;  
}  


2.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;  
}  


3.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;  
}  



你可能感兴趣的:(BestCoder Round #50 (div.2)(hdu 5364,hdu 5365,hdu 5366))